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 <sgarz...@redhat.com> > --- > 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), > };
signature.asc
Description: OpenPGP digital signature