]> git.hungrycats.org Git - linux/commit
btrfs: count METADATA_REMAP chunks as metadata in the balance limit_min check
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 11 Nov 2026 05:32:48 +0000 (00:32 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 11 Nov 2026 05:32:48 +0000 (00:32 -0500)
commit9a23ab44cc809803844029845e6c70bab32ce3ee
treec2850f822a2e2ffa8093afec5ae90c338aa521bf
parent0000f9ffa253abd087bd4e32a6868715e6c36830
btrfs: count METADATA_REMAP chunks as metadata in the balance limit_min check

should_balance_chunk() already treats a METADATA_REMAP chunk as a
metadata chunk: the metadata type flag selects it, the metadata filters
apply to it, and it is charged against the metadata limit or limit_max
when it is selected, so the remap chunks queued by __btrfs_balance()
stay within the MAX of -mlimit=MIN..MAX.  The counting pass of
__btrfs_balance() also counts it in count_meta.

The limit_min check in the second pass is the only place that tests the
raw METADATA bit, which a METADATA_REMAP chunk does not have.  With
-mlimit=MIN..MAX and fewer than MIN matching metadata chunks, the
balance skips every METADATA chunk, as asked, but still relocates the
METADATA_REMAP chunk.

Test the METADATA_REMAP bit in that check as well, so that remap chunks
count as metadata in both passes and the limit bounds the total number
of block groups relocated.

Fixes: 81e5a4551c32 ("btrfs: allow balancing remap tree")
Assisted-by: Claude:claude-opus-5-5
fs/btrfs/volumes.c