On Mon, Jun 26, 2023 at 07:08:32PM +0300, Andrey Drobyshev via wrote: > 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. > > Signed-off-by: Andrey Drobyshev <andrey.drobys...@virtuozzo.com> > --- > block.c | 7 +++++++ > block/qcow2.c | 1 + > include/block/block-common.h | 5 +++++ > 3 files changed, 13 insertions(+) > > diff --git a/block.c b/block.c > index 0637265c26..4fe1743cfb 100644 > --- a/block.c > +++ b/block.c > @@ -6392,6 +6392,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 either not supported.
s/either/are/ > + * Then it is safe to treat each cluster as having only one > subcluster. > + */ > + bdi->subcluster_size = bdi->cluster_size; > + } Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org