]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: replace identity remaps with actual remaps when doing relocations
authorMark Harmstone <mark@harmstone.com>
Wed, 7 Jan 2026 14:09:13 +0000 (14:09 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:54:35 +0000 (07:54 +0100)
commitfd6594b1446cc753450bad8d0da6288da1ad7b96
treefd3b49a16e6a872c53c54f148e431f9728e188d6
parentbbea42dfb91f6901243958c83f26bbbd3a4a85fa
btrfs: replace identity remaps with actual remaps when doing relocations

Add a function do_remap_tree_reloc(), which does the actual work of
doing a relocation using the remap tree.

In a loop we call do_remap_reloc_trans(), which searches for the first
identity remap for the block group. We call btrfs_reserve_extent() to
find space elsewhere for it, and read the data into memory and write it
to the new location. We then carve out the identity remap and replace it
with an actual remap, which points to the new location in which to look.

Once the last identity remap has been removed we call
last_identity_remap_gone(), which, as with deletions, removes the
chunk's stripes and device extents.

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/relocation.c