]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: snap_protect: verify layering is supported
authorDan Mick <dan.mick@inktank.com>
Fri, 17 Aug 2012 23:01:15 +0000 (16:01 -0700)
committerDan Mick <dan.mick@inktank.com>
Sat, 18 Aug 2012 01:48:13 +0000 (18:48 -0700)
src/librbd/internal.cc

index 689541fa923cb8e3c20bcfff509e759da24ea25b..dea3682aa0a8730cf08c20e97e56bc91c4a2d201 100644 (file)
@@ -491,6 +491,13 @@ namespace librbd {
 
     Mutex::Locker l(ictx->md_lock);
     Mutex::Locker l2(ictx->snap_lock);
+    uint64_t features;
+    ictx->get_features(ictx->snap_id, &features);
+    if ((features & RBD_FEATURE_LAYERING) == 0) {
+      lderr(ictx->cct) << "snap_protect: image must support layering"
+                      << dendl;
+      return -ENOSYS;
+    }
     snap_t snap_id = ictx->get_snap_id(snap_name);
     if (snap_id == CEPH_NOSNAP)
       return -ENOENT;
@@ -522,9 +529,9 @@ namespace librbd {
     if (r < 0)
       return r;
 
-    uint64_t features;
     Mutex::Locker l(ictx->md_lock);
     Mutex::Locker l2(ictx->snap_lock);
+    uint64_t features;
     ictx->get_features(ictx->snap_id, &features);
     if ((features & RBD_FEATURE_LAYERING) == 0) {
       lderr(ictx->cct) << "snap_unprotect: image must support layering"