btrfs: zoned: fix alloc_offset calculation for partly conventional block groups
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Fri, 6 Jun 2025 07:17:41 +0000 (09:17 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 19 Jun 2025 13:21:15 +0000 (15:21 +0200)
commitc0d90a79e8e65b89037508276b2b31f41a1b3783
tree187ab923531b007b7a6eea8957aed60bc0ee04e2
parent547e836661554dcfa15c212a3821664e85b4191a
btrfs: zoned: fix alloc_offset calculation for partly conventional block groups

When one of two zones composing a DUP block group is a conventional zone,
we have the zone_info[i]->alloc_offset = WP_CONVENTIONAL. That will, of
course, not match the write pointer of the other zone, and fails that
block group.

This commit solves that issue by properly recovering the emulated write
pointer from the last allocated extent. The offset for the SINGLE, DUP,
and RAID1 are straight-forward: it is same as the end of last allocated
extent. The RAID0 and RAID10 are a bit tricky that we need to do the math
of striping.

This is the kernel equivalent of Naohiro's user-space commit:
"btrfs-progs: zoned: fix alloc_offset calculation for partly
conventional block groups".

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zoned.c