From: Qu Wenruo <wqu@suse.com>
To: Guanjie Chen <jk.chen1095@gmail.com>
Cc: clm@fb.com, dsterba@suse.com, fdmanana@suse.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: free qgroup configuration when quota enable fails
Date: Sat, 15 Aug 2026 07:43:21 +0930 [thread overview]
Message-ID: <7845cec2-adf1-408f-b7eb-019a5cd398f7@suse.com> (raw)
In-Reply-To: <20260814123034.19289-1-jk.chen1095@gmail.com>
在 2026/8/14 22:00, Guanjie Chen 写道:
> Hi Qu,
>
>> We can reach this out branch if btrfs_start_transaction() failed, but
>> the fs_info->quota_root is already setup by another process.
>
> Do you mean the window where qgroup_ioctl_lock is dropped before
> btrfs_start_transaction()?
>
> I don't think another task can set fs_info->quota_root in that window.
> The quota ioctl holds fs_info->subvol_sem for writing across the whole
> btrfs_quota_enable() call, including while qgroup_ioctl_lock is dropped.
>
> As far as I can see, quota_root is only set in two places:
> btrfs_quota_enable(), which is serialized by subvol_sem, and
> btrfs_read_roots(), which runs during mount initialization.
Right, I missed that rwsem.
But still, for error handling one should be in the reverse order.
And for out: label, there are cases we're going out label without
creating any qgroup. In that case, qgroups removing should be done only
for cases where a qgroup is created.
>
> The disable path also calls btrfs_free_qgroup_config() and relies on the
> same subvol_sem and qgroup_ioctl_lock serialization for the qgroup
> configuration. If subvol_sem did not prevent another quota operation
> here, the disable path would have a similar lifetime problem.
>
> So if quota_root was NULL at the first check, I believe it must still be
> NULL when btrfs_start_transaction() fails. I agree that the changelog
> should have mentioned subvol_sem as part of the protection.
>
> Did I miss another runtime path that can set quota_root without holding
> subvol_sem?
>
> Also, just to clarify, this is not my first btrfs contribution, although
> my previous change was only a small one.
The same, LLM disclosure if you're using it.
Nowadays I won't trust anyone who is not a regular contributor.
>
> Thanks,
> Guanjie
next prev parent reply other threads:[~2026-08-14 22:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 11:22 [PATCH] btrfs: free qgroup configuration when quota enable fails Guanjie Chen
2026-08-14 11:49 ` Qu Wenruo
2026-08-14 12:30 ` Guanjie Chen
2026-08-14 22:13 ` Qu Wenruo [this message]
2026-08-15 6:44 ` Guanjie Chen
2026-08-15 8:03 ` Qu Wenruo
[not found] <d239645a-b291-4fe9-b256-f0be849c875a@suse.com@suse.com>
2026-08-15 9:00 ` Guanjie Chen
2026-08-15 9:08 ` Qu Wenruo
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=7845cec2-adf1-408f-b7eb-019a5cd398f7@suse.com \
--to=wqu@suse.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=jk.chen1095@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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