qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] block/rbd: increase dynamically the image si


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v3] block/rbd: increase dynamically the image size
Date: Tue, 25 Jun 2019 16:02:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 09.05.19 16:59, Stefano Garzarella wrote:
> RBD APIs don't allow us to write more than the size set with
> rbd_create() or rbd_resize().
> In order to support growing images (eg. qcow2), we resize the
> image before write operations that exceed the current size.
> 
> Signed-off-by: Stefano Garzarella <address@hidden>
> ---
> v3:
>   - add 'image_size' field in the BDRVRBDState to keep track of the
>     current size of the RBD image [Jason, Kevin]
> ---
>  block/rbd.c | 42 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 39 insertions(+), 3 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 0c549c9935..b0355a2ce0 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c

[...]

> @@ -833,6 +842,22 @@ static void qemu_rbd_close(BlockDriverState *bs)
>      rados_shutdown(s->cluster);
>  }
>  
> +/* Resize the RBD image and update the 'image_size' with the current size */
> +static int qemu_rbd_resize(BlockDriverState *bs, uint64_t size)
> +{
> +    BDRVRBDState *s = bs->opaque;
> +    int r;
> +
> +    r = rbd_resize(s->image, size);
> +    if (r < 0) {
> +        return r;
> +    }
> +
> +    s->image_size = size;

I think this should update bs->total_sectors, too.  In fact, I’m
wondering why you don’t just use bs->total_sectors (or bdrv_getlength(),
which returns bs->total_sectors * 512) instead of adding this new field?

Max

> +
> +    return 0;
> +}
> +
>  static const AIOCBInfo rbd_aiocb_info = {
>      .aiocb_size = sizeof(RBDAIOCB),
>  };

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]