linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] btrfs: qgroup: update qgroup in memory at the same time when we update it in btree.
@ 2021-08-25 10:29 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-08-25 10:29 UTC (permalink / raw)
  To: linux-btrfs

[ Ancient code - dan]

The patch e8c8541ac379: "btrfs: qgroup: update qgroup in memory at
the same time when we update it in btree." from Nov 20, 2014, leads
to the following Smatch static checker warning:

	fs/btrfs/qgroup.c:2850 btrfs_qgroup_inherit()
	warn: sleeping in atomic context

fs/btrfs/qgroup.c
    2817         if (inherit) {
    2818                 i_qgroups = (u64 *)(inherit + 1);
    2819                 for (i = 0; i < inherit->num_qgroups; ++i, ++i_qgroups) {
    2820                         if (*i_qgroups == 0)
    2821                                 continue;
    2822                         ret = add_qgroup_relation_item(trans, objectid,
    2823                                                        *i_qgroups);
    2824                         if (ret && ret != -EEXIST)
    2825                                 goto out;
    2826                         ret = add_qgroup_relation_item(trans, *i_qgroups,
    2827                                                        objectid);
    2828                         if (ret && ret != -EEXIST)
    2829                                 goto out;
    2830                 }
    2831                 ret = 0;
    2832         }
    2833 
    2834 
    2835         spin_lock(&fs_info->qgroup_lock);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Holding a lock.

    2836 
    2837         dstgroup = add_qgroup_rb(fs_info, objectid);
    2838         if (IS_ERR(dstgroup)) {
    2839                 ret = PTR_ERR(dstgroup);
    2840                 goto unlock;
    2841         }
    2842 
    2843         if (inherit && inherit->flags & BTRFS_QGROUP_INHERIT_SET_LIMITS) {
    2844                 dstgroup->lim_flags = inherit->lim.flags;
    2845                 dstgroup->max_rfer = inherit->lim.max_rfer;
    2846                 dstgroup->max_excl = inherit->lim.max_excl;
    2847                 dstgroup->rsv_rfer = inherit->lim.rsv_rfer;
    2848                 dstgroup->rsv_excl = inherit->lim.rsv_excl;
    2849 
--> 2850                 ret = update_qgroup_limit_item(trans, dstgroup);
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This function calls btrfs_alloc_path() which sleeps.

    2851                 if (ret) {
    2852                         fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
    2853                         btrfs_info(fs_info,
    2854                                    "unable to update quota limit for %llu",
    2855                                    dstgroup->qgroupid);
    2856                         goto unlock;
    2857                 }
    2858         }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-25 10:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 10:29 [bug report] btrfs: qgroup: update qgroup in memory at the same time when we update it in btree Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).