From: Stefano Garzarella <sgarzare@redhat.com> To: Kevin Wolf <kwolf@redhat.com> Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>, Josh Durgin <jdurgin@redhat.com> Subject: Re: [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size Date: Mon, 29 Apr 2019 16:04:27 +0200 [thread overview] Message-ID: <20190429140427.6tfpvdzza3io46g5@steredhat> (raw) In-Reply-To: <20190429102510.GD8492@localhost.localdomain> On Mon, Apr 29, 2019 at 12:25:10PM +0200, Kevin Wolf wrote: > 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 <sgarzare@redhat.com> > > --- > > 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? I'm not sure we can use bs->total_sectors. IIUC, for example, it doesn't take care of bytes used by QCOW2 metadata. > > > 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. Yes, I'll change the behaviour in the v2. I did some tries (i.e. using qemu-io and reading more than bytes used) and the RBD driver didn't receive 'read' requests that exceed the current size, maybe because it is managed in the QCOW2 protocol, but of course I'll handle also in the RBD driver. Thanks, Stefano
WARNING: multiple messages have this Message-ID (diff)
From: Stefano Garzarella <sgarzare@redhat.com> To: Kevin Wolf <kwolf@redhat.com> Cc: Josh Durgin <jdurgin@redhat.com>, qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH RFC 1/1] block/rbd: increase dynamically the image size Date: Mon, 29 Apr 2019 16:04:27 +0200 [thread overview] Message-ID: <20190429140427.6tfpvdzza3io46g5@steredhat> (raw) Message-ID: <20190429140427.CW3zdyefF0O8og5txwWhi1JuI_Ilm6h0mten9hCa-lE@z> (raw) In-Reply-To: <20190429102510.GD8492@localhost.localdomain> On Mon, Apr 29, 2019 at 12:25:10PM +0200, Kevin Wolf wrote: > 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 <sgarzare@redhat.com> > > --- > > 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? I'm not sure we can use bs->total_sectors. IIUC, for example, it doesn't take care of bytes used by QCOW2 metadata. > > > 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. Yes, I'll change the behaviour in the v2. I did some tries (i.e. using qemu-io and reading more than bytes used) and the RBD driver didn't receive 'read' requests that exceed the current size, maybe because it is managed in the QCOW2 protocol, but of course I'll handle also in the RBD driver. Thanks, Stefano
next prev parent reply other threads:[~2019-04-29 14:04 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-11 10:50 [Qemu-devel] [PATCH RFC 0/1] block/rbd: increase dynamically the image size Stefano Garzarella 2019-04-11 10:50 ` Stefano Garzarella 2019-04-11 10:50 ` [Qemu-devel] [PATCH RFC 1/1] " Stefano Garzarella 2019-04-11 10:50 ` Stefano Garzarella 2019-04-11 12:35 ` Jason Dillaman 2019-04-11 12:35 ` Jason Dillaman 2019-04-11 13:02 ` Stefano Garzarella 2019-04-11 13:02 ` Stefano Garzarella 2019-04-11 17:06 ` Jason Dillaman 2019-04-11 17:06 ` Jason Dillaman 2019-04-14 13:20 ` Stefano Garzarella 2019-04-14 13:20 ` Stefano Garzarella 2019-04-14 15:14 ` Jason Dillaman 2019-04-14 15:14 ` Jason Dillaman 2019-04-15 8:04 ` Kevin Wolf 2019-04-15 8:04 ` Kevin Wolf 2019-04-17 7:34 ` Stefano Garzarella 2019-04-17 7:34 ` Stefano Garzarella 2019-04-17 8:04 ` Kevin Wolf 2019-04-17 8:04 ` Kevin Wolf 2019-04-19 12:23 ` Stefano Garzarella 2019-04-19 12:23 ` Stefano Garzarella 2019-04-23 7:56 ` Kevin Wolf 2019-04-23 7:56 ` Kevin Wolf 2019-04-23 8:26 ` Stefano Garzarella 2019-04-23 8:26 ` Stefano Garzarella 2019-04-23 8:38 ` Kevin Wolf 2019-04-23 8:38 ` Kevin Wolf 2019-04-29 9:58 ` [Qemu-devel] [Qemu-block] " Kevin Wolf 2019-04-29 9:58 ` Kevin Wolf 2019-04-29 10:11 ` Stefano Garzarella 2019-04-29 10:11 ` Stefano Garzarella 2019-04-29 10:25 ` [Qemu-devel] " Kevin Wolf 2019-04-29 10:25 ` Kevin Wolf 2019-04-29 14:04 ` Stefano Garzarella [this message] 2019-04-29 14:04 ` Stefano Garzarella 2019-04-29 14:30 ` Kevin Wolf 2019-04-29 14:30 ` Kevin Wolf 2019-04-29 15:55 ` Stefano Garzarella 2019-04-29 15:55 ` Stefano Garzarella
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=20190429140427.6tfpvdzza3io46g5@steredhat \ --to=sgarzare@redhat.com \ --cc=jdurgin@redhat.com \ --cc=kwolf@redhat.com \ --cc=mreitz@redhat.com \ --cc=qemu-block@nongnu.org \ --cc=qemu-devel@nongnu.org \ /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: linkBe 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).