]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: force removal of a snapshot cannot ignore dependent children 20135/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 24 Jan 2018 19:40:56 +0000 (14:40 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 26 Jan 2018 13:11:01 +0000 (08:11 -0500)
Fixes: http://tracker.ceph.com/issues/22791
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit fcc58ecfeba6bbc72588e69dba35779f94d28ba5)

src/librbd/internal.cc

index ee57371ce15b7d1bc0ff4eb3d4480277115b2f89..e6b860c03008531fad96ed7b47d8aadeacc01048 100644 (file)
@@ -608,6 +608,14 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
          return r;
        }
 
+        if ((imctx->features & RBD_FEATURE_DEEP_FLATTEN) == 0 &&
+            !imctx->snaps.empty()) {
+          lderr(cct) << "snapshot in-use by " << pool << "/" << imctx->name
+                     << dendl;
+          imctx->state->close();
+          return -EBUSY;
+        }
+
        librbd::NoOpProgressContext prog_ctx;
        r = imctx->operations->flatten(prog_ctx);
        if (r < 0) {
@@ -617,21 +625,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
          return r;
        }
 
-       if ((imctx->features & RBD_FEATURE_DEEP_FLATTEN) == 0 &&
-           !imctx->snaps.empty()) {
-         imctx->parent_lock.get_read();
-         ParentInfo parent_info = imctx->parent_md;
-         imctx->parent_lock.put_read();
-
-         r = cls_client::remove_child(&imctx->md_ctx, RBD_CHILDREN,
-                                      parent_info.spec, imctx->id);
-         if (r < 0 && r != -ENOENT) {
-           lderr(cct) << "error removing child from children list" << dendl;
-           imctx->state->close();
-           return r;
-         }
-       }
-
        r = imctx->state->close();
         if (r < 0) {
           lderr(cct) << "failed to close image: " << cpp_strerror(r) << dendl;