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>
---
Changes since v1:
-Improved commit log.
-Picked up tag.
block/file-posix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 3c985da94f..63c52b1044 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1495,7 +1495,7 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st,
bs->bl.max_append_sectors = ret >> BDRV_SECTOR_BITS;
}
- ret = get_sysfs_long_val(st, "physical_block_size");
+ ret = get_sysfs_long_val(st, "zone_write_granularity");
if (ret >= 0) {
bs->bl.write_granularity = ret;
}
--
2.55.0
On Tue, Aug 11, 2026 at 03:32:36PM +0200, Niklas Cassel wrote:
> 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>
> ---
Stefan,
Since you already have another zoned storage fix for file-posix.c queued:
https://gitlab.com/stefanha/qemu/-/commits/block-next
Could you perhaps queue this one as well?
Kind regards,
Niklas
On Tue, Aug 11, 2026 at 03:32:36PM +0200, Niklas Cassel wrote:
> 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>
> ---
> Changes since v1:
> -Improved commit log.
> -Picked up tag.
>
> block/file-posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
© 2016 - 2026 Red Hat, Inc.