From: Sage Weil Date: Fri, 29 Mar 2013 04:29:55 +0000 (-0700) Subject: rbd: fail import-diff if end snap already exists X-Git-Tag: v0.62~118^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9946c69cd1b83c90129c88a6866e95482dffbc8a;p=ceph.git rbd: fail import-diff if end snap already exists This will prevent a user from inadvertantly reapplying a diff twice. Signed-off-by: Sage Weil --- diff --git a/qa/workunits/rbd/diff.sh b/qa/workunits/rbd/diff.sh index 1e79d7cf9d3c..8218ae28dab5 100755 --- a/qa/workunits/rbd/diff.sh +++ b/qa/workunits/rbd/diff.sh @@ -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 diff --git a/src/rbd.cc b/src/rbd.cc index 1bfe3d35911a..23d9d045d9f0 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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;