]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fail import-diff if end snap already exists
authorSage Weil <sage@inktank.com>
Fri, 29 Mar 2013 04:29:55 +0000 (21:29 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 1 Apr 2013 06:32:41 +0000 (23:32 -0700)
This will prevent a user from inadvertantly reapplying a diff twice.

Signed-off-by: Sage Weil <sage@inktank.com>
qa/workunits/rbd/diff.sh
src/rbd.cc

index 1e79d7cf9d3c93080b94c0faec21488d17fe33bc..8218ae28dab5311a053aa7042ad5bf9d94ee4582 100755 (executable)
@@ -27,6 +27,7 @@ rm foo.diff
 
 rbd export-diff foo@three --from-snap two foo.diff
 rbd import-diff foo.diff foo.copy
+rbd import-diff foo.diff foo.copy && exit 1 || true   # this should fail with EEXIST on the end snap
 rbd snap ls foo.copy | grep three
 
 rbd export foo foo.out
index 1bfe3d35911ab61aa4ded6b5d2a8f9b0b111bbb3..23d9d045d9f03276ba06e29d020776ba631b06c3 100644 (file)
@@ -1424,6 +1424,13 @@ static int do_import_diff(librbd::Image &image, const char *path)
       if (r < 0)
        goto done;
       dout(2) << "   to snap " << to << dendl;
+
+      // verify this snap isn't already present
+      if (image.snap_exists(to.c_str())) {
+       cerr << "end snapshot '" << to << "' already exists, aborting" << std::endl;
+       r = -EEXIST;
+       goto done;
+      }
     }
     else if (tag == 's') {
       uint64_t end_size;