]> git.hungrycats.org Git - linux/commit
btrfs: stripe_meta: maintain trapped free space for metadata groups like data
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 5 Sep 2026 09:50:29 +0000 (05:50 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 18 Sep 2026 21:36:27 +0000 (17:36 -0400)
commit8a859a8c528ebf83cdcbf59110726e9f7d847cb7
treef57d60e7323fcaf10dd65dc1c659d92d735f9ef3
parente762b203367699a935bddbe5643defa36a607470
btrfs: stripe_meta: maintain trapped free space for metadata groups like data

btrfs_block_group_init_stripe_unusable() arms stripe_meta groups and adds
their trapped bytes to the METADATA space_info, but the disarm, rescan
and commit-time scan only accept btrfs_is_stripe_alloc_bg() (DATA), so
a metadata group's contribution was frozen at its first value: never
updated as tree blocks were freed inside stripes, never dropped when the
group went read-only or was removed.  Tree blocks can only be placed in
fully free stripes, so the trapped bytes are as unusable as for data and
need the same maintenance.

Accept stripe_meta groups on the three maintenance paths, let the commit
scan sum METADATA space_infos, and apply the read-only subtraction to
the metadata branch of inc_block_group_ro() as well.

Assisted-by: Claude:claude-fable-5
fs/btrfs/block-group.c
fs/btrfs/free-space-cache.c