public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Leo Martins <loemra.dev@gmail.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: avoid GFP_ATOMIC allocations in qgroup free paths
Date: Mon, 23 Mar 2026 13:20:45 +0100	[thread overview]
Message-ID: <20260323122045.GJ5735@twin.jikos.cz> (raw)
In-Reply-To: <44a36cda2b9cdc4a600c942c051f9e028239308b.1773941507.git.loemra.dev@gmail.com>

On Thu, Mar 19, 2026 at 04:49:08PM -0700, Leo Martins wrote:
> 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>

Added to for-next, thanks.

      parent reply	other threads:[~2026-03-23 12:20 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
2026-03-23 12:20 ` David Sterba [this message]

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=20260323122045.GJ5735@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --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