From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Leo Martins <loemra.dev@gmail.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: avoid GFP_ATOMIC allocations in qgroup free paths
Date: Fri, 20 Mar 2026 11:20:16 +1030 [thread overview]
Message-ID: <edf6986d-40dc-47a4-81dd-9946d103bbf1@gmx.com> (raw)
In-Reply-To: <44a36cda2b9cdc4a600c942c051f9e028239308b.1773941507.git.loemra.dev@gmail.com>
在 2026/3/20 10:19, Leo Martins 写道:
> When qgroups are enabled, __btrfs_qgroup_release_data() and
> qgroup_free_reserved_data() pass an extent_changeset to
> btrfs_clear_record_extent_bits() to track how many bytes had their
> EXTENT_QGROUP_RESERVED bits cleared. Inside the extent IO tree spinlock,
> add_extent_changeset() calls ulist_add() with GFP_ATOMIC to record each
> changed range. If this allocation fails, it hits a BUG_ON and panics the
> kernel.
>
> However, both of these callers only read changeset.bytes_changed
> afterwards — the range_changed ulist is populated and immediately freed
> without ever being iterated. The GFP_ATOMIC allocation is entirely
> unnecessary for these paths.
>
> Introduce extent_changeset_init_bytes_only() which uses a sentinel value
> (EXTENT_CHANGESET_BYTES_ONLY) on the ulist's prealloc field to signal
> that only bytes_changed should be tracked. add_extent_changeset() checks
> for this sentinel and returns early after updating bytes_changed,
> skipping the ulist_add() call entirely. This eliminates the GFP_ATOMIC
> allocation and makes the BUG_ON unreachable for these paths.
>
> Callers that need range tracking (qgroup_reserve_data,
> qgroup_unreserve_range, btrfs_qgroup_check_reserved_leak) continue to
> use extent_changeset_init() and are unaffected.
>
> Signed-off-by: Leo Martins <loemra.dev@gmail.com>
Looks good to me.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
next prev parent reply other threads:[~2026-03-20 0:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 23:49 [PATCH] btrfs: avoid GFP_ATOMIC allocations in qgroup free paths Leo Martins
2026-03-20 0:50 ` Qu Wenruo [this message]
2026-03-23 12:20 ` David Sterba
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=edf6986d-40dc-47a4-81dd-9946d103bbf1@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=loemra.dev@gmail.com \
/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