[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH RFC 1/1] block/rbd: increase dynamically the ima
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-block] [PATCH RFC 1/1] block/rbd: increase dynamically the image size |
Date: |
Mon, 29 Apr 2019 12:25:10 +0200 |
User-agent: |
Mutt/1.11.3 (2019-02-01) |
Am 11.04.2019 um 12:50 hat Stefano Garzarella geschrieben:
> 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 RW operations that exceed the current size.
>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1171007
> Signed-off-by: Stefano Garzarella <address@hidden>
> ---
> block/rbd.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/block/rbd.c b/block/rbd.c
> index 0c549c9935..228658e20a 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -102,6 +102,7 @@ typedef struct BDRVRBDState {
> rbd_image_t image;
> char *image_name;
> char *snap;
> + uint64_t image_size;
> } BDRVRBDState;
Can't we use bs->total_sectors instead of adding a new image_size field?
> static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
> @@ -777,6 +778,14 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict
> *options, int flags,
> goto failed_open;
> }
>
> + r = rbd_get_size(s->image, &s->image_size);
> + if (r < 0) {
> + error_setg_errno(errp, -r, "error reading image size from %s",
> + s->image_name);
> + rbd_close(s->image);
> + goto failed_open;
> + }
> +
> /* If we are using an rbd snapshot, we must be r/o, otherwise
> * leave as-is */
> if (s->snap != NULL) {
> @@ -921,6 +930,20 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
> rcb->buf = acb->bounce;
> }
>
> + /*
> + * RBD APIs don't allow us to write more than actual size, so in order
> + * to support growing images, we resize the image before RW operations
> + * that exceed the current size.
> + */
> + if (s->image_size < off + size) {
> + r = rbd_resize(s->image, off + size);
> + if (r < 0) {
> + goto failed;
> + }
> +
> + s->image_size = off + size;
> + }
This doesn't check the request type, so it's actually not limited to RW
operations, but even reads will try to resize the image. This is at
least surprising. For regular files, file-posix extends the file for
write requests, but for reads it returns a zeroed buffer without
actually changing the file size.
Kevin
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, (continued)
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Jason Dillaman, 2019/04/14
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Kevin Wolf, 2019/04/15
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Stefano Garzarella, 2019/04/17
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Kevin Wolf, 2019/04/17
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Stefano Garzarella, 2019/04/19
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Kevin Wolf, 2019/04/23
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Stefano Garzarella, 2019/04/23
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Kevin Wolf, 2019/04/23
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Kevin Wolf, 2019/04/29
- Re: [Qemu-block] [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size, Stefano Garzarella, 2019/04/29
Re: [Qemu-block] [PATCH RFC 1/1] block/rbd: increase dynamically the image size,
Kevin Wolf <=