qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@virtuozzo.com>
To: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>,
	qemu-block@nongnu.org,  qemu-stable@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com,
	vsementsov@yandex-team.ru, eblake@redhat.com
Subject: Re: [PATCH 1/3] block: add subcluster_size field to BlockDriverInfo
Date: Tue, 11 Jul 2023 18:57:33 +0200	[thread overview]
Message-ID: <0ecaafdf-e5dd-f260-b07f-8a91c37b2270@virtuozzo.com> (raw)
In-Reply-To: <20230626160834.696680-2-andrey.drobyshev@virtuozzo.com>

On 6/26/23 18:08, Andrey Drobyshev 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.drobyshev@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.
> +         * 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 e23edd48c2..94b8d0e1c2 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;
> 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;
Reviewed-by: Denis V. Lunev <den@openvz.org>


  parent reply	other threads:[~2023-07-11 16:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 16:08 [PATCH 0/3] block: align CoR requests to subclusters Andrey Drobyshev via
2023-06-26 16:08 ` [PATCH 1/3] block: add subcluster_size field to BlockDriverInfo Andrey Drobyshev via
2023-07-10 19:44   ` Eric Blake
2023-07-11 16:57   ` Denis V. Lunev [this message]
2023-06-26 16:08 ` [PATCH 2/3] block/io: align requests to subcluster_size Andrey Drobyshev via
2023-07-10 19:47   ` Eric Blake
2023-07-11 17:46     ` Andrey Drobyshev
2023-07-11 17:05   ` Denis V. Lunev
2023-06-26 16:08 ` [PATCH 3/3] tests/qemu-iotests/197: add testcase for CoR with subclusters Andrey Drobyshev via
2023-07-10 19:50   ` Eric Blake
2023-07-11 17:05   ` Denis V. Lunev
2023-07-07 11:33 ` [PATCH 0/3] block: align CoR requests to subclusters Andrey Drobyshev

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=0ecaafdf-e5dd-f260-b07f-8a91c37b2270@virtuozzo.com \
    --to=den@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --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).