From: Dan Mick Date: Tue, 6 Nov 2012 00:13:19 +0000 (-0800) Subject: rbd: allow removal of image even if rbd_children deletion fails X-Git-Tag: v0.54~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=241569c595a770183fa3597eeb66b709660123ad;p=ceph.git rbd: allow removal of image even if rbd_children deletion fails 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 Reviewed-by: Josh Durgin --- diff --git a/qa/workunits/rbd/copy.sh b/qa/workunits/rbd/copy.sh index b7ca82e6fce5..86a365cbf71f 100755 --- a/qa/workunits/rbd/copy.sh +++ b/qa/workunits/rbd/copy.sh @@ -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() { diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 703566013a78..6bf613cc3620 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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; }