[PATCH v2 for 5.3.0] storage_backend_rbd: Ignore rbd_diff_iterate error() if needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When cloning an RBD volume we try to find a snapshot which is
not different to the image we're trying to clone. This boils down
to calling rbd_diff_iterate() or rbd_diff_iterate2() on systems
with newer ceph. These two are passed a callback -
virStorageBackendRBDIterateCb() which sets @diff to 1 and returns
-1. The idea is to stop iterating as soon as possible (i.e. we're
iterating over a snapshot with some deltas). Unfortunately,
returning a negative value from the callback means that iterate()
function fails and thus we report an error:

  virsh # vol-clone --pool rbd_image_root coreos_2023 coreos00.disk
  error: Failed to clone vol from coreos_2023
  error: failed to iterate RBD snapshot coreos_2023@base: Operation not
  permitted

Therefore, report an error if and only if it doesn't originates
in the callback.

Reported on libvirt-users list:

https://www.redhat.com/archives/libvirt-users/2019-April/msg00060.html

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---

diff to v1:
- Ignore error as suggested by Jason as it allows us to exit iteration
early.

 src/storage/storage_backend_rbd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index f8c968e682..69f4fa2117 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -1101,7 +1101,9 @@ virStorageBackendRBDSnapshotFindNoDiff(rbd_image_t image,
                              virStorageBackendRBDIterateCb, (void *)&diff);
 #endif
 
-        if (r < 0) {
+        /* We care for errors only if the callback wasn't called at all. If it
+         * was, rbd_diff_iterate() returns an error which we have to ignore. */
+        if (r < 0 && diff == 0) {
             virReportSystemError(-r, _("failed to iterate RBD snapshot %s@%s"),
                                  imgname, snaps[i].name);
             goto cleanup;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux