]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: force removal of a snapshot cannot ignore dependent children 20105/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 24 Jan 2018 19:40:56 +0000 (14:40 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 25 Jan 2018 22:13:12 +0000 (17:13 -0500)
Fixes: http://tracker.ceph.com/issues/22791
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index 8357f58728a9ae7fc3255457d56f0e1f4ba4381f..deda99c87c8a543443e8b55e2c4397e034caee78 100644 (file)
@@ -594,6 +594,14 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
          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) {
@@ -603,21 +611,6 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
          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;