]> git.hungrycats.org Git - linux/commit
btrfs: honor allocator hints for fixed-width mirrors
authorKeinNiemand <18308201+KeinNiemand@users.noreply.github.com>
Sun, 30 Aug 2026 12:50:54 +0000 (14:50 +0200)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:06:49 +0000 (21:06 -0500)
commitfa401eea94fa3a52dca7cd8b069048cd825bd17d
tree1965e877a89d04cb1f96be7416085fbe25c0951f
parentaed367c3e614ba93a1410fc2308842cfd35c68a0
btrfs: honor allocator hints for fixed-width mirrors

gather_device_info() admits complete allocation-hint groups until it
has at least devs_min devices. It then clears the hints and sorts the
admitted devices globally by max_avail. For a fixed-width mirrored
profile, that second sort can move preferred devices past the later
devs_max cutoff.

RAID1, RAID1C3 and RAID1C4 currently use exactly devs_min devices.
Limit the hint-ordered prefix to that fixed count before clearing the
hints. Devices within each hint group are already ordered by max_avail,
so this keeps the best devices needed from the final group.
The existing second sort then restores the max_avail ordering expected
by stripe-size calculation over the selected devices only.

Check that devs_min and devs_max match instead of relying on the
current RAID1 profile definitions implicitly. If a future RAID1 profile
becomes variable-width, it will retain the existing whole-group
behavior.

Leave all other profiles unchanged, in particular the wide striped
profiles that need the complete final candidate group.

A preferred device remains eligible while it has at least
dev_extent_min free. It can therefore constrain stripe_size and produce
a small block group. This behavior already exists when the preferred
tier alone satisfies the profile; this change intentionally extends it
to fixed-width mirrors assembled from multiple hint tiers.

v2:
- Document the possible chunk-size constraint from a nearly full
  preferred device.

Assisted-by: Codex:GPT-5
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: KeinNiemand <18308201+KeinNiemand@users.noreply.github.com>
Signed-off-by: Kai Krakow <kai@kaishome.de>
fs/btrfs/volumes.c