[libvirt] [PATCH v2 2/2] storage: RBD: do not return error when deleting non-existent volume

Martin Kletzander mkletzan at redhat.com
Tue Jun 2 12:47:32 UTC 2015


On Thu, May 28, 2015 at 05:29:55PM +0200, Erik Skultety wrote:
>RBD API returns negative value of errno, in that case we can silently
>ignore if RBD tries to delete a non-existent volume, just like FS
>backend does.
>---
> src/storage/storage_backend_rbd.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
>index ae4bcb3..8e8d7a7 100644
>--- a/src/storage/storage_backend_rbd.c
>+++ b/src/storage/storage_backend_rbd.c
>@@ -1,7 +1,7 @@
> /*
>  * storage_backend_rbd.c: storage backend for RBD (RADOS Block Device) handling
>  *
>- * Copyright (C) 2013-2014 Red Hat, Inc.
>+ * Copyright (C) 2013-2015 Red Hat, Inc.
>  * Copyright (C) 2012 Wido den Hollander

I wonder how come nobody complained in reply to this patch already...

>  *
>  * This library is free software; you can redistribute it and/or
>@@ -426,7 +426,7 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
>     VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name);
>
>     if (flags & VIR_STORAGE_VOL_DELETE_ZEROED)
>-        VIR_WARN("%s", _("This storage backend does not supported zeroed removal of volumes"));
>+        VIR_WARN("%s", _("This storage backend does not support zeroed removal of volumes"));
>

This could be another trivial patch, but it's *so* trivial, I'm OK
with keeping it here.

>     if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0)
>         goto cleanup;
>@@ -435,7 +435,7 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
>         goto cleanup;
>
>     r = rbd_remove(ptr.ioctx, vol->name);
>-    if (r < 0) {
>+    if (r < 0 && (-r) != ENOENT) {

This makes sense.  ACK.

>         virReportSystemError(-r, _("failed to remove volume '%s/%s'"),
>                              pool->def->source.name, vol->name);
>         goto cleanup;
>--
>1.9.3
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150602/dd10ff0c/attachment-0001.sig>


More information about the libvir-list mailing list