]> 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>
Sun, 8 Nov 2026 06:08:58 +0000 (01:08 -0500)
commitcead1690f27b9c8e91df192e7fb51d860c18a830
tree74fa8553e74c36c2cc74f515742304261be38047
parente34929a04b50ed8cfe3cc37b7a9f96a886a7947f
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