]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: replace snap_exists with a new safer version
authorxiexingguo <xie.xingguo@zte.com.cn>
Sat, 19 Dec 2015 06:53:47 +0000 (14:53 +0800)
committerxiexingguo <xie.xingguo@zte.com.cn>
Sun, 20 Dec 2015 08:23:48 +0000 (16:23 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/tools/rbd/action/ImportDiff.cc

index 9f600f8285d8d149d0f69f2940a561628e1d8ec9..21a817cbbe652061992ed1900b19445f37fbf8ad 100644 (file)
@@ -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;