[libvirt] [PATCH] rbd: Allow shrinking and deltas when resizing RBD volumes

John Ferlan jferlan at redhat.com
Sat Feb 6 12:22:53 UTC 2016



On 01/30/2016 10:15 AM, Wido den Hollander wrote:
> Modify virCheckFlags that it accepts both VIR_STORAGE_VOL_RESIZE_DELTA
> and VIR_STORAGE_VOL_RESIZE_SHRINK as valid flags for resizing RBD
> volumes.
> 
> This still does not solve the problem where RBD volumes can't be
> shrinked using libvirt. The allocation and capacity of RBD volumes
> are equal for a RBD volume and this makes libvirt think the volume
> is fully allocated and therefor can't be shrinked.

'shrinked' is just a strange word.  Typically it's shrunk (US movie
"Honey I shrunk the kids". Still the problem seems to be that shrinking
an RBD volume ran into problems because allocation and capacity values
are checked by the driver and perhaps some assumptions made about the
underlying storage

In any case - is what you're seeing because the storage_driver
(storageVolResize) has some checks?  Could you provide some context? Is
it this check?:

   if (abs_capacity < vol->target.allocation) {
        virReportError(VIR_ERR_INVALID_ARG, "%s",
                       _("can't shrink capacity below "
                         "existing allocation"));
        goto cleanup;
    }

Since only _fs and _sheepdog support 'resizeVol' - maybe those checks
are more _fs specific rather than general for all storage drivers.

> 
> Signed-off-by: Wido den Hollander <wido at widodh.nl>
> ---
>  src/storage/storage_backend_rbd.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
> index 80a1d33..88b613a 100644
> --- a/src/storage/storage_backend_rbd.c
> +++ b/src/storage/storage_backend_rbd.c
> @@ -1041,7 +1041,8 @@ static int virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
>      int ret = -1;
>      int r = 0;
>  
> -    virCheckFlags(0, -1);
> +    virCheckFlags(VIR_STORAGE_VOL_RESIZE_DELTA |
> +                  VIR_STORAGE_VOL_RESIZE_SHRINK, -1);
>  
>      if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
>          goto cleanup;
> 

To add to Jan's comments, the virsh-volume.c tells us 'delta' is just a
way to tell the storage driver that capacity is delta to current size
rather than the new size.

Perhaps a better explanation in virStorageVolResize to indicate that the
flag is used only by the storage driver.

Also, I would assume _rbd can increase (ALLOCATE) too, right?

John




More information about the libvir-list mailing list