All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] file-posix: fix zone write granularity assignment for zoned block devices
@ 2026-08-07 18:02 Niklas Cassel
  2026-08-07 18:06 ` Niklas Cassel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Niklas Cassel @ 2026-08-07 18:02 UTC (permalink / raw)
  To: Kevin Wolf, Hanna Reitz
  Cc: qemu-block, qemu-devel, Sam Li, Stefan Hajnoczi, Damien Le Moal,
	Niklas Cassel

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 by providing, 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.

Fixes: a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
 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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] file-posix: fix zone write granularity assignment for zoned block devices
  2026-08-07 18:02 [PATCH] file-posix: fix zone write granularity assignment for zoned block devices Niklas Cassel
@ 2026-08-07 18:06 ` Niklas Cassel
  2026-08-07 19:00 ` Damien Le Moal
  2026-08-11 13:45 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Niklas Cassel @ 2026-08-07 18:06 UTC (permalink / raw)
  To: Kevin Wolf, Hanna Reitz
  Cc: qemu-block, qemu-devel, Sam Li, Stefan Hajnoczi, Damien Le Moal

On Fri, Aug 07, 2026 at 08:02:57PM +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 by providing, so let's make use of it.

nit:
this away, so let's make use of it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] file-posix: fix zone write granularity assignment for zoned block devices
  2026-08-07 18:02 [PATCH] file-posix: fix zone write granularity assignment for zoned block devices Niklas Cassel
  2026-08-07 18:06 ` Niklas Cassel
@ 2026-08-07 19:00 ` Damien Le Moal
  2026-08-11 13:45 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2026-08-07 19:00 UTC (permalink / raw)
  To: Niklas Cassel, Kevin Wolf, Hanna Reitz
  Cc: qemu-block, qemu-devel, Sam Li, Stefan Hajnoczi

On 2026/08/07 11:02, 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 by providing, so let's make use of it.

s/by providing// ? Seems like the sentence is not complete otherwise...

> 
> 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.
> 
> Fixes: a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers")
> Signed-off-by: Niklas Cassel <cassel@kernel.org>

Other than that, looks OK to me.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>


-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] file-posix: fix zone write granularity assignment for zoned block devices
  2026-08-07 18:02 [PATCH] file-posix: fix zone write granularity assignment for zoned block devices Niklas Cassel
  2026-08-07 18:06 ` Niklas Cassel
  2026-08-07 19:00 ` Damien Le Moal
@ 2026-08-11 13:45 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2026-08-11 13:45 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Kevin Wolf, Hanna Reitz, qemu-block, qemu-devel, Sam Li,
	Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]

On Fri, Aug 07, 2026 at 08:02:57PM +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 by providing, 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.
> 
> Fixes: a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers")
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
>  block/file-posix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-11 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 18:02 [PATCH] file-posix: fix zone write granularity assignment for zoned block devices Niklas Cassel
2026-08-07 18:06 ` Niklas Cassel
2026-08-07 19:00 ` Damien Le Moal
2026-08-11 13:45 ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.