From: Niklas Cassel <cassel@kernel.org>
To: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
Sam Li <faithilikerun@gmail.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Damien Le Moal <dlemoal@kernel.org>,
Niklas Cassel <cassel@kernel.org>
Subject: [PATCH] file-posix: fix zone write granularity assignment for zoned block devices
Date: Fri, 7 Aug 2026 20:02:57 +0200 [thread overview]
Message-ID: <20260807180257.813627-1-cassel@kernel.org> (raw)
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
next reply other threads:[~2026-08-07 18:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 18:02 Niklas Cassel [this message]
2026-08-07 18:06 ` [PATCH] file-posix: fix zone write granularity assignment for zoned block devices Niklas Cassel
2026-08-07 19:00 ` Damien Le Moal
2026-08-11 13:45 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260807180257.813627-1-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=faithilikerun@gmail.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.