Message ID | 20201227164236.10143-4-pl@kamp.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block/rbd: migrate to coroutines and add write zeroes support | expand |
On Sun, Dec 27, 2020 at 11:42 AM Peter Lieven <pl@kamp.de> wrote: > > Signed-off-by: Peter Lieven <pl@kamp.de> > --- > block/rbd.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/block/rbd.c b/block/rbd.c > index bc8cf8af9b..a2da70e37f 100644 > --- a/block/rbd.c > +++ b/block/rbd.c > @@ -956,15 +956,7 @@ static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi) > static int64_t qemu_rbd_getlength(BlockDriverState *bs) > { > BDRVRBDState *s = bs->opaque; > - rbd_image_info_t info; > - int r; > - > - r = rbd_stat(s->image, &info, sizeof(info)); > - if (r < 0) { > - return r; > - } > - > - return info.size; > + return s->image_size; > } > > static int coroutine_fn qemu_rbd_co_truncate(BlockDriverState *bs, > -- > 2.17.1 An RBD image can technically change size dynamically while in-use. The original code would provide the most up-to-date length but this version will always return the size of the image when it was opened. -- Jason
Am 14.01.21 um 20:18 schrieb Jason Dillaman: > On Sun, Dec 27, 2020 at 11:42 AM Peter Lieven <pl@kamp.de> wrote: >> Signed-off-by: Peter Lieven <pl@kamp.de> >> --- >> block/rbd.c | 10 +--------- >> 1 file changed, 1 insertion(+), 9 deletions(-) >> >> diff --git a/block/rbd.c b/block/rbd.c >> index bc8cf8af9b..a2da70e37f 100644 >> --- a/block/rbd.c >> +++ b/block/rbd.c >> @@ -956,15 +956,7 @@ static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi) >> static int64_t qemu_rbd_getlength(BlockDriverState *bs) >> { >> BDRVRBDState *s = bs->opaque; >> - rbd_image_info_t info; >> - int r; >> - >> - r = rbd_stat(s->image, &info, sizeof(info)); >> - if (r < 0) { >> - return r; >> - } >> - >> - return info.size; >> + return s->image_size; >> } >> >> static int coroutine_fn qemu_rbd_co_truncate(BlockDriverState *bs, >> -- >> 2.17.1 > An RBD image can technically change size dynamically while in-use. The > original code would provide the most up-to-date length but this > version will always return the size of the image when it was opened. Agreed, but Qemu won't propagate this info to the guest unless Qemu truncate is called with length 0. Anyway, if we want support this we should adjust s->image_size if the size has changed. Peter
diff --git a/block/rbd.c b/block/rbd.c index bc8cf8af9b..a2da70e37f 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -956,15 +956,7 @@ static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi) static int64_t qemu_rbd_getlength(BlockDriverState *bs) { BDRVRBDState *s = bs->opaque; - rbd_image_info_t info; - int r; - - r = rbd_stat(s->image, &info, sizeof(info)); - if (r < 0) { - return r; - } - - return info.size; + return s->image_size; } static int coroutine_fn qemu_rbd_co_truncate(BlockDriverState *bs,
Signed-off-by: Peter Lieven <pl@kamp.de> --- block/rbd.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)