From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Xu" <peterx@redhat.com>, "Thomas Huth" <thuth@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Fam Zheng" <fam@euphon.net>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"John Snow" <jsnow@redhat.com>,
"Jeuk Kim" <jeuk20.kim@samsung.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Leonardo Bras" <leobras@redhat.com>,
qemu-block@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Denis V . Lunev" <den@openvz.org>,
"Andrey Drobyshev" <andrey.drobyshev@virtuozzo.com>
Subject: [PULL 6/8] block: add subcluster_size field to BlockDriverInfo
Date: Thu, 24 Aug 2023 12:58:31 -0400 [thread overview]
Message-ID: <20230824165833.1689137-7-stefanha@redhat.com> (raw)
In-Reply-To: <20230824165833.1689137-1-stefanha@redhat.com>
From: Andrey Drobyshev via <qemu-devel@nongnu.org>
This is going to be used in the subsequent commit as requests alignment
(in particular, during copy-on-read). This value only makes sense for
the formats which support subclusters (currently QCOW2 only). If this
field isn't set by driver's own bdrv_get_info() implementation, we
simply set it equal to the cluster size thus treating each cluster as
having a single subcluster.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230711172553.234055-2-andrey.drobyshev@virtuozzo.com>
---
include/block/block-common.h | 5 +++++
block.c | 7 +++++++
block/qcow2.c | 1 +
3 files changed, 13 insertions(+)
diff --git a/include/block/block-common.h b/include/block/block-common.h
index e15395f2cb..df5ffc8d09 100644
--- a/include/block/block-common.h
+++ b/include/block/block-common.h
@@ -132,6 +132,11 @@ typedef struct BlockZoneWps {
typedef struct BlockDriverInfo {
/* in bytes, 0 if irrelevant */
int cluster_size;
+ /*
+ * A fraction of cluster_size, if supported (currently QCOW2 only); if
+ * disabled or unsupported, set equal to cluster_size.
+ */
+ int subcluster_size;
/* offset at which the VM state can be saved (0 if not possible) */
int64_t vm_state_offset;
bool is_dirty;
diff --git a/block.c b/block.c
index a307c151a8..0af890f647 100644
--- a/block.c
+++ b/block.c
@@ -6480,6 +6480,13 @@ int coroutine_fn bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
}
memset(bdi, 0, sizeof(*bdi));
ret = drv->bdrv_co_get_info(bs, bdi);
+ if (bdi->subcluster_size == 0) {
+ /*
+ * If the driver left this unset, subclusters are not supported.
+ * Then it is safe to treat each cluster as having only one subcluster.
+ */
+ bdi->subcluster_size = bdi->cluster_size;
+ }
if (ret < 0) {
return ret;
}
diff --git a/block/qcow2.c b/block/qcow2.c
index c51388e99d..b48cd9ce63 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -5197,6 +5197,7 @@ qcow2_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVQcow2State *s = bs->opaque;
bdi->cluster_size = s->cluster_size;
+ bdi->subcluster_size = s->subcluster_size;
bdi->vm_state_offset = qcow2_vm_state_offset(s);
bdi->is_dirty = s->incompatible_features & QCOW2_INCOMPAT_DIRTY;
return 0;
--
2.41.0
next prev parent reply other threads:[~2023-08-24 17:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 16:58 [PULL 0/8] Block patches Stefan Hajnoczi
2023-08-24 16:58 ` [PULL 1/8] hw/ufs: Initial commit for emulated Universal-Flash-Storage Stefan Hajnoczi
2023-08-24 16:58 ` [PULL 2/8] hw/ufs: Support for Query Transfer Requests Stefan Hajnoczi
2023-08-24 16:58 ` [PULL 3/8] hw/ufs: Support for UFS logical unit Stefan Hajnoczi
2023-08-24 16:58 ` [PULL 4/8] tests/qtest: Introduce tests for UFS Stefan Hajnoczi
2023-08-24 16:58 ` [PULL 5/8] block-migration: Ensure we don't crash during migration cleanup Stefan Hajnoczi
2023-08-24 16:58 ` Stefan Hajnoczi [this message]
2023-08-24 16:58 ` [PULL 7/8] block/io: align requests to subcluster_size Stefan Hajnoczi
2023-08-24 16:58 ` [PULL 8/8] tests/qemu-iotests/197: add testcase for CoR with subclusters 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=20230824165833.1689137-7-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=berrange@redhat.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jeuk20.kim@samsung.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=leobras@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@redhat.com \
--cc=vsementsov@yandex-team.ru \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).