]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: allow balancing remap tree
authorMark Harmstone <mark@harmstone.com>
Wed, 7 Jan 2026 14:09:15 +0000 (14:09 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:54:36 +0000 (07:54 +0100)
commit81e5a4551c32b454468f5aa3fe45dabb6bccb854
tree35de319082ee33be126beb7f801e9cbb8f513dd7
parenta645372e7e40be088828ad99aa9a6c68f83ef00d
btrfs: allow balancing remap tree

Balancing the METADATA_REMAP chunk, i.e. the chunk in which the remap tree
lives, is a special case.

We can't use the remap tree itself for this, as then we'd have no way to
boostrap it on mount. And we can't use the pre-remap tree code for this
as it relies on walking the extent tree, and we're not creating backrefs
for METADATA_REMAP chunks.

So instead, if a balance would relocate any METADATA_REMAP block groups, mark
those block groups as readonly and COW every leaf of the remap tree.

There's more sophisticated ways of doing this, such as only COWing nodes
within a block group that's to be relocated, but they're fiddly and with
lots of edge cases. Plus it's not anticipated that

a) the number of METADATA_REMAP chunks is going to be particularly large, or

b) that users will want to only relocate some of these chunks - the main
   use case here is to unbreak RAID conversion and device removal.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c