]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: don't overwrite the error code from the remove action 20481/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 19 Feb 2018 13:27:58 +0000 (08:27 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 19 Feb 2018 14:35:31 +0000 (09:35 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd/action/Remove.cc

index 397b05a75fd5314af17f1b4efbe523d3267c5b76..c19696d7199203efdc8e166cd1b911be2afb681a 100644 (file)
@@ -84,11 +84,11 @@ int execute(const po::variables_map &vm,
     if (r == -ENOTEMPTY) {
       librbd::Image image;
       std::vector<librbd::snap_info_t> snaps;
-      r = utils::open_image(io_ctx, image_name, true, &image);
-      if (r >= 0) {
-        r = image.snap_list(snaps);
+      int image_r = utils::open_image(io_ctx, image_name, true, &image);
+      if (image_r >= 0) {
+        image_r = image.snap_list(snaps);
       }
-      if (r >= 0) {
+      if (image_r >= 0) {
         snaps.erase(std::remove_if(snaps.begin(), snaps.end(),
                                   [&image](const librbd::snap_info_t& snap) {
                                      return is_auto_delete_snapshot(&image,
@@ -124,8 +124,8 @@ int execute(const po::variables_map &vm,
         std::string pool_name = "";
         librados::Rados rados(io_ctx);
         librados::IoCtx pool_io_ctx;
-        r = rados.ioctx_create2(group_info.pool, pool_io_ctx);
-        if (r < 0) {
+        image_r = rados.ioctx_create2(group_info.pool, pool_io_ctx);
+        if (image_r < 0) {
           pool_name = "<missing data pool " + stringify(group_info.pool) + ">";
         } else {
           pool_name = pool_io_ctx.get_pool_name();
@@ -142,7 +142,7 @@ int execute(const po::variables_map &vm,
     } else {
       std::cerr << "rbd: delete error: " << cpp_strerror(r) << std::endl;
     }
-    return r ;
+    return r;
   }
   return 0;
 }