]> 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:39 +0000 (00:32 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 11 Nov 2026 05:32:39 +0000 (00:32 -0500)
commitdfba5a10a3a1cd8c68f0f6a0de1d870f11fd8cfd
tree5696af76f22a8980615e02841a19a24a4d47c310
parentd0f2ca5a3c8bed7bcbac5259c956322c3942411a
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