linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [bug report] btrfs: qgroup: update qgroup in memory at the same time when we update it in btree.
Date: Wed, 25 Aug 2021 13:29:17 +0300	[thread overview]
Message-ID: <20210825102917.GA2486@kili> (raw)

[ 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

                 reply	other threads:[~2021-08-25 10:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210825102917.GA2486@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).