From: Niklas Cassel <cassel@kernel.org>
To: qemu-devel@nongnu.org
Cc: Niklas Cassel <cassel@kernel.org>,
dlemoal@kernel.org, Stefan Hajnoczi <stefanha@redhat.com>,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Hanna Reitz <hreitz@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
qemu-block@nongnu.org, Sam Li <faithilikerun@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
Jeuk Kim <jeuk20.kim@samsung.com>,
Daejun Park <daejun7.park@samsung.com>
Subject: [PATCH v16 8/9] block: add accessors for the zone model, capacity and open zone limit
Date: Fri, 30 Oct 2026 18:10:35 +0100 [thread overview]
Message-ID: <20261030171038.702962-9-cassel@kernel.org> (raw)
In-Reply-To: <20261030171038.702962-1-cassel@kernel.org>
Add the block-backend accessors blk_get_zone_model(),
blk_get_zone_capacity() and blk_get_max_open_zones(), which report the
zoned model, the zone capacity and the maximum number of open zones of
the backing device, mirroring the existing blk_get_zone_size(). This
lets device models query the zoned geometry without dereferencing
BlockDriverState internals.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
block/block-backend.c | 33 +++++++++++++++++++++++++++++++
include/system/block-backend-io.h | 3 +++
2 files changed, 36 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 656c0aed67..397ec9ed5a 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -2338,6 +2338,39 @@ uint64_t blk_get_zone_size(BlockBackend *blk)
return bs ? bs->bl.zone_size : 0;
}
+/*
+ * Returns the zoned model of @blk (BLK_Z_HM, BLK_Z_HA), or BLK_Z_NONE if
+ * @blk does not present zoned geometry.
+ */
+BlockZoneModel blk_get_zone_model(BlockBackend *blk)
+{
+ BlockDriverState *bs = blk_bs(blk);
+ IO_CODE();
+ return bs ? bs->bl.zoned : BLK_Z_NONE;
+}
+
+/*
+ * Returns the maximum number of simultaneously open zones for a zoned
+ * backend, or 0 if there is no limit or @blk is not zoned.
+ */
+uint32_t blk_get_max_open_zones(BlockBackend *blk)
+{
+ BlockDriverState *bs = blk_bs(blk);
+ IO_CODE();
+ return bs ? bs->bl.max_open_zones : 0;
+}
+
+/*
+ * Returns how many bytes of each zone of @blk can be written (the zone
+ * capacity), or 0 if that is not known.
+ */
+uint64_t blk_get_zone_capacity(BlockBackend *blk)
+{
+ BlockDriverState *bs = blk_bs(blk);
+ IO_CODE();
+ return bs ? bs->bl.zone_capacity : 0;
+}
+
/* Returns the optimal write zeroes alignment, in bytes; guaranteed nonzero */
uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk)
{
diff --git a/include/system/block-backend-io.h b/include/system/block-backend-io.h
index 78d410b8df..7c958843b4 100644
--- a/include/system/block-backend-io.h
+++ b/include/system/block-backend-io.h
@@ -122,6 +122,9 @@ uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk);
uint32_t blk_get_max_transfer(BlockBackend *blk);
uint64_t blk_get_max_hw_transfer(BlockBackend *blk);
uint64_t blk_get_zone_size(BlockBackend *blk);
+BlockZoneModel blk_get_zone_model(BlockBackend *blk);
+uint32_t blk_get_max_open_zones(BlockBackend *blk);
+uint64_t blk_get_zone_capacity(BlockBackend *blk);
int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
BlockBackend *blk_out, int64_t off_out,
--
2.56.0
next prev parent reply other threads:[~2026-10-30 17:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 17:10 [PATCH v16 0/9] Add full zoned storage emulation to the qcow2 driver Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 1/9] docs/qcow2: add the zoned format feature Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 2/9] qcow2: add configurations for zoned format extension Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 3/9] block: define errnos for zone protocol errors Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 4/9] qcow2: add zoned emulation capability Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 5/9] iotests: test the zoned format feature for qcow2 file Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 6/9] qcow2: validate the write pointer table when opening an image Niklas Cassel
2026-10-30 17:10 ` [PATCH v16 7/9] virtio-blk: report zone errors with their zone status codes Niklas Cassel
2026-10-30 17:10 ` Niklas Cassel [this message]
2026-10-30 17:10 ` [PATCH v16 9/9] scsi: add the sense codes of zoned block devices Niklas Cassel
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=20261030171038.702962-9-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=armbru@redhat.com \
--cc=daejun7.park@samsung.com \
--cc=dlemoal@kernel.org \
--cc=eblake@redhat.com \
--cc=faithilikerun@gmail.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jeuk20.kim@samsung.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pierrick.bouvier@oss.qualcomm.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.