]> git.hungrycats.org Git - linux/commit
btrfs: stripe_meta: extend stripe reclaim to metadata block groups
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 22 Oct 2026 20:47:05 +0000 (16:47 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:16:31 +0000 (21:16 -0500)
commit7bbd02b12369623c5d6702945f527862dac9be01
treed99ae8a2af10f535577234b17c1a70d400fece1a
parent07d7670e8ed5d3320c868687be4039b24606fcc1
btrfs: stripe_meta: extend stripe reclaim to metadata block groups

The stripe reclaim of the reclaim subtopic handles stripe_alloc data block
groups only.  stripe_meta allocates tree blocks in whole stripes too, so
its block groups trap free space in partially used stripes the same way,
and that space comes back only by moving the live tree blocks out of those
stripes.  Metadata needs it more than data: a metadata reservation that
finds no claimable stripe aborts the transaction instead of failing one
write, so trapped metadata space that is never reclaimed ends in a forced
read-only filesystem.

Extend each reclaim mechanism to stripe_meta block groups:

 - btrfs_reclaim_block_group(): allocate a chunk to relocate into when the
   other groups' claimable stripes cannot take the group's live bytes, and
   relocate the group even while it has reserved or pinned bytes.  Under
   COW, a metadata group always has tree blocks reserved or pinned, so the
   generic bail-out would defer it forever.

 - The cleaner's periodic re-evaluation scans the metadata space_info as
   well as the data one.

 - Compaction counts metadata extent items: a tree block is nodesize long
   and never spans a stripe, so for a metadata group the closure is the
   partial stripes themselves.

 - stripe_reclaim_now accepts stripe_meta block groups, for one group or
   for all of them.

The comments that name the groups reclaim handles now name both.

Assisted-by: Claude:claude-opus-5-5
fs/btrfs/block-group.c
fs/btrfs/free-space-cache.c
fs/btrfs/fs.h
fs/btrfs/relocation.c
fs/btrfs/sysfs.c
fs/btrfs/volumes.c