]> git.hungrycats.org Git - linux/commit
btrfs: add allocator_hint mode
authorKai Krakow <kai@kaishome.de>
Fri, 10 Jul 2026 22:18:02 +0000 (00:18 +0200)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:06:49 +0000 (21:06 -0500)
commitb63eb52872e2dcd8dccf55f558dac73e180644b4
treee78dc6462b9e83c4bfc5cf750bb7f8dcbee9c3ae
parentab7714e82aea77d30ef03f5e53637a4bc09cd4d2
btrfs: add allocator_hint mode

When this mode is enabled, the chunk allocation policy is modified as
follows:

Each disk may have a different tag:
- BTRFS_DEV_ALLOCATION_PREFERRED_METADATA
- BTRFS_DEV_ALLOCATION_METADATA_ONLY
- BTRFS_DEV_ALLOCATION_DATA_ONLY
- BTRFS_DEV_ALLOCATION_PREFERRED_DATA (default)

Where:
- ALLOCATION_PREFERRED_X means that it is preferred to use this disk
  for the X chunk type (the other type may be allowed when the space is
  low)
- ALLOCATION_X_ONLY means that it is used *only* for the X chunk type.
  This means also that it is a preferred choice.

Each time the allocator allocates a chunk of type X, first it takes the
disks tagged as ALLOCATION_X_ONLY or ALLOCATION_PREFERRED_X.

If the space is not enough, it uses also the disks tagged as
ALLOCATION_METADATA_ONLY.

If the space is not enough, it uses also the other disks, with the
exception of the one marked as ALLOCATION_PREFERRED_Y, where Y is the
other type of chunk (i.e. not X).

Mixed data and metadata block groups intentionally ignore all hints. They
cannot separate the two chunk classes and are outside the tiering use case
targeted by this feature.

The current type-based interface also has two known limitations: device
replace does not copy hints to the target device, and hint updates are not
serialized with concurrent chunk allocation.

v2:
- Document the mixed-block-group scope and the limitations of the
  type-based interface.

Co-authored-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: Kai Krakow <kai@kaishome.de>
fs/btrfs/Kconfig
fs/btrfs/volumes.c
fs/btrfs/volumes.h