]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: allow removal of image even if rbd_children deletion fails
authorDan Mick <dan.mick@inktank.com>
Tue, 6 Nov 2012 00:13:19 +0000 (16:13 -0800)
committerDan Mick <dan.mick@inktank.com>
Tue, 6 Nov 2012 05:41:34 +0000 (21:41 -0800)
Users have been seeing failures where rbd rm is half-done; could be
because of outstanding watches on the rbd_header object.  The state
is that rbd_children no longer contains the child, but other pieces
remain; remove considers this a failure.

Fix: test for ENOENT from remove_child, and treat that as an ignorable
error and drive on.  Simulate this in copy.sh by removing the
rbd_children object altogether, which also results in ENOENT return
from remove_child.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
qa/workunits/rbd/copy.sh
src/librbd/internal.cc

index b7ca82e6fce553e37ebb16b37e6a56ef9dfce94b..86a365cbf71ff5ee62af8fe190eab2ff9aaf180e 100755 (executable)
@@ -153,6 +153,21 @@ test_remove() {
     rados -p rbd rm rbd_id.test2
     rbd rm test2
     rbd ls | wc -l | grep "^0$"
+
+    # remove with rbd_children object missing (and, by extension,
+    # with child not mentioned in rbd_children)
+    rbd create --new-format -s 1 test2
+    rbd snap create test2@snap
+    rbd snap protect test2@snap
+    rbd clone test2@snap clone
+
+    rados -p rbd rm rbd_children
+    rbd rm clone
+    rbd ls | grep clone | wc -l | grep '^0$'
+
+    rbd snap unprotect test2@snap
+    rbd snap rm test2@snap
+    rbd rm test2
 }
 
 test_locking() {
index 703566013a783e6bcb3c3feb5634bafd924bf8d0..6bf613cc3620f85f96b05972f48a8a2f2503c998 100644 (file)
@@ -1216,7 +1216,7 @@ reprotect_and_return_err:
       if (scan_for_parents(ictx, parent_info.spec, CEPH_NOSNAP) == -ENOENT) {
        r = cls_client::remove_child(&ictx->md_ctx, RBD_CHILDREN,
                                     parent_info.spec, id);
-       if (r < 0) {
+       if (r < 0 && r != -ENOENT) {
          lderr(cct) << "error removing child from children list" << dendl;
          return r;
        }