]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: add METADATA_REMAP chunk type
authorMark Harmstone <mark@harmstone.com>
Wed, 7 Jan 2026 14:09:02 +0000 (14:09 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:54:27 +0000 (07:54 +0100)
commit0b4d29fa98ca1a49c4498353253f857573871ba0
tree0de2957d4eb36cad681d2fcb7004ef1a40e2804a
parentef6a31d035a1000071dc4846aebd02ad081db9e4
btrfs: add METADATA_REMAP chunk type

Add a new METADATA_REMAP chunk type, which is a metadata chunk that holds the
remap tree.

This is needed for bootstrapping purposes: the remap tree can't itself
be remapped, and must be relocated the existing way, by COWing every
leaf. The remap tree can't go in the SYSTEM chunk as space there is
limited, because a copy of the chunk item gets placed in the superblock.

The changes in fs/btrfs/volumes.h are because we're adding a new block
group type bit after the profile bits, and so can no longer rely on the
const_ilog2 trick.

The sizing to 32MB per chunk, matching the SYSTEM chunk, is an estimate
here, we can adjust it later if it proves to be too big or too small.
This works out to be ~500,000 remap items, which for a 4KB block size
covers ~2GB of remapped data in the worst case and ~500TB in the best case.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-rsv.c
fs/btrfs/block-rsv.h
fs/btrfs/disk-io.c
fs/btrfs/fs.h
fs/btrfs/space-info.c
fs/btrfs/sysfs.c
fs/btrfs/tree-checker.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h
include/uapi/linux/btrfs_tree.h