@samitouri / QOSamiQemu / commits / 8e02b06882

file-posix: fix zone write granularity assignment for zoned block devices

In the ZBC and ZAC specifications, the requirement is that the write granularity matches the physical block size. However, in the ZNS specification, the requirement is simply that the write granularity matches the logical block size. See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a805a4fa4fa376bbc145762bb8b09caa2fa8af48 In Linux, there is a zone_write_granularity sysfs property which abstracts this away, so let's make use of it. Currently, it is theoretically possible that QEMU presents an inflated write granularity for NVMe devices where the physical block size is larger than the logical block size. Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Fixes: a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers") Signed-off-by: Niklas Cassel <cassel@kernel.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Niklas Cassel committed Aug 11, 2026 at 15:32 UTC 8e02b06882e5742fb760138e3db627a8591bdef3
1 file changed +1 -1
block/file-posix.c
+1 -1
@@ -1493,7 +1493,7 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st,
1493 bs->bl.max_append_sectors = ret >> BDRV_SECTOR_BITS;
1494 }
1495
1496 - ret = get_sysfs_long_val(st, "physical_block_size");
1496 + ret = get_sysfs_long_val(st, "zone_write_granularity");
1497 if (ret >= 0) {
1498 bs->bl.write_granularity = ret;
1499 }