diff options
| author | Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> | 2023-07-11 20:25:51 +0300 |
|---|---|---|
| committer | Stefan Hajnoczi <stefanha@redhat.com> | 2023-08-30 07:39:10 -0400 |
| commit | c54483b6f45a0c84e230728a1a9e7adf90345e15 (patch) | |
| tree | 5bf9bacf290a472997dc5cb756125cf5eb92ba9f /block.c | |
| parent | f187609f27b261702a17f79d20bf252ee0d4f9cd (diff) | |
| download | focaccia-qemu-c54483b6f45a0c84e230728a1a9e7adf90345e15.tar.gz focaccia-qemu-c54483b6f45a0c84e230728a1a9e7adf90345e15.zip | |
block: add subcluster_size field to BlockDriverInfo
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>
Diffstat (limited to 'block.c')
| -rw-r--r-- | block.c | 7 |
1 files changed, 7 insertions, 0 deletions
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; } |