From: xiexingguo Date: Sat, 19 Dec 2015 06:53:47 +0000 (+0800) Subject: tools: replace snap_exists with a new safer version X-Git-Tag: v10.0.3~190^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=084f22ce15eb200e859ba03a76636bf78d9eeba3;p=ceph.git tools: replace snap_exists with a new safer version Signed-off-by: xie xingguo --- diff --git a/src/tools/rbd/action/ImportDiff.cc b/src/tools/rbd/action/ImportDiff.cc index 9f600f8285d8..21a817cbbe65 100644 --- a/src/tools/rbd/action/ImportDiff.cc +++ b/src/tools/rbd/action/ImportDiff.cc @@ -74,7 +74,12 @@ static int do_import_diff(librbd::Image &image, const char *path, goto done; dout(2) << " from snap " << from << dendl; - if (!image.snap_exists(from.c_str())) { + bool exists; + r = image.snap_exists2(from.c_str(), &exists); + if (r < 0) + goto done; + + if (!exists) { std::cerr << "start snapshot '" << from << "' does not exist in the image, aborting" << std::endl; r = -EINVAL; @@ -88,7 +93,12 @@ static int do_import_diff(librbd::Image &image, const char *path, dout(2) << " to snap " << to << dendl; // verify this snap isn't already present - if (image.snap_exists(to.c_str())) { + bool exists; + r = image.snap_exists2(to.c_str(), &exists); + if (r < 0) + goto done; + + if (exists) { std::cerr << "end snapshot '" << to << "' already exists, aborting" << std::endl; r = -EEXIST;