]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
review: librbd, test_librbd: make "protect protected snap" fail
authorDan Mick <dan.mick@inktank.com>
Fri, 17 Aug 2012 20:00:48 +0000 (13:00 -0700)
committerDan Mick <dan.mick@inktank.com>
Sat, 18 Aug 2012 01:47:45 +0000 (18:47 -0700)
src/librbd/internal.cc
src/test/test_librbd.cc

index 5d4523a0051b165918a70660c53ad8892595be20..6ed2c44ea84296bf4afe29690cdd3e305121be00 100644 (file)
@@ -495,6 +495,15 @@ namespace librbd {
     if (snap_id == CEPH_NOSNAP)
       return -ENOENT;
 
+    uint8_t prot;
+    r = cls_client::get_protection_status(&ictx->md_ctx, ictx->header_oid,
+                                         snap_id, &prot);
+    if (r < 0)
+      return r;
+
+    if (prot == RBD_PROTECTION_STATUS_PROTECTED) 
+      return -EBUSY;
+    
     r = cls_client::set_protection_status(&ictx->md_ctx,
                                          ictx->header_oid,
                                          snap_id,
index f1661cc298bfbd4353619ea75e9b359f7f4e5d01..5b0ff096afba3d8c87e32d24c0a0da519246b30e 100644 (file)
@@ -1005,6 +1005,9 @@ TEST(LibRBD, TestClone)
            features, &order));
 
   ASSERT_EQ(0, rbd_snap_protect(parent, "parent_snap"));
+  // protecting again should fail
+  ASSERT_EQ(-EBUSY, rbd_snap_protect(parent, "parent_snap"));
+  printf("can't protect a protected snap\n");
 
   // This clone and open should work
   ASSERT_EQ(0, rbd_clone(ioctx, "parent", "parent_snap", ioctx, "child",