]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: ensure fast diff feature relies on object map
authorJason Dillaman <dillaman@redhat.com>
Thu, 26 Mar 2015 01:09:47 +0000 (21:09 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 13 Apr 2015 19:24:15 +0000 (15:24 -0400)
Throw an error if the fast diff feature is enabled w/o the
object map -- or if the object map is disabled while fast
diff is still enabled.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index af79d946586d5050d94200cd30a951b55ed6ed49..522352fc7ad8842d7fdbbb46d9ca938fe26f11d3 100644 (file)
@@ -1013,7 +1013,11 @@ reprotect_and_return_err:
       }
     }
 
-    if ((features & RBD_FEATURE_OBJECT_MAP) != 0) {
+    if ((features & RBD_FEATURE_FAST_DIFF) != 0 &&
+        (features & RBD_FEATURE_OBJECT_MAP) == 0) {
+      lderr(cct) << "cannot use fast diff without object map" << dendl;
+      goto err_remove_header;
+    } else if ((features & RBD_FEATURE_OBJECT_MAP) != 0) {
       if ((features & RBD_FEATURE_EXCLUSIVE_LOCK) == 0) {
         lderr(cct) << "cannot use object map without exclusive lock" << dendl;
         goto err_remove_header;
@@ -1505,6 +1509,12 @@ reprotect_and_return_err:
           return -EINVAL;
         }
         mask |= RBD_FEATURE_EXCLUSIVE_LOCK;
+      } else if ((features & RBD_FEATURE_FAST_DIFF) != 0) {
+        if ((ictx->features & RBD_FEATURE_OBJECT_MAP) == 0) {
+          lderr(cct) << "cannot enable fast diff" << dendl;
+          return -EINVAL;
+        }
+        mask |= (RBD_FEATURE_OBJECT_MAP | RBD_FEATURE_EXCLUSIVE_LOCK);
       }
     } else {
       if ((features & RBD_FEATURE_EXCLUSIVE_LOCK) != 0) {
@@ -1514,6 +1524,10 @@ reprotect_and_return_err:
         }
         mask |= RBD_FEATURE_OBJECT_MAP;
       } else if ((features & RBD_FEATURE_OBJECT_MAP) != 0) {
+        if ((ictx->features & RBD_FEATURE_FAST_DIFF) != 0) {
+          lderr(cct) << "cannot disable object map" << dendl;
+          return -EINVAL;
+        }
         r = remove_object_map(ictx);
         if (r < 0) {
           lderr(cct) << "failed to remove object map" << dendl;