]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd: don't clear CLONE_CHILD op feature if still a child
authorJason Dillaman <dillaman@redhat.com>
Mon, 12 Feb 2018 20:01:28 +0000 (15:01 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 13 Feb 2018 14:14:16 +0000 (09:14 -0500)
After removing the last snapshot linked to a parent image,
don't clear the CLONE_CHILD op feature bit if the image HEAD
is still linked to the parent.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd.cc

index dda49c96e6e70d7f9f9b77b3e03a6e295222a145..0cb447f435470fdaeeb57c6153fd558a866886b2 100644 (file)
@@ -2002,8 +2002,15 @@ int snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
     return r;
   }
 
+  cls_rbd_parent parent;
+  r = read_key(hctx, "parent", &parent);
+  if (r < 0 && r != -ENOENT) {
+    return r;
+  }
+  bool has_parent = (r >= 0 && parent.pool != -1);
+
   uint64_t op_features_mask = 0ULL;
-  if (!has_child_snaps) {
+  if (!has_child_snaps && !has_parent) {
     // disable clone child op feature if no longer associated
     op_features_mask |= RBD_OPERATION_FEATURE_CLONE_CHILD;
   }