]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: group misc cleanup 20199/head
authorsongweibin <song.weibin@zte.com.cn>
Wed, 31 Jan 2018 08:56:35 +0000 (16:56 +0800)
committersongweibin <song.weibin@zte.com.cn>
Thu, 1 Feb 2018 00:29:11 +0000 (08:29 +0800)
* Add some error message when returning a negative error code.
* Validate dest name when renaming a group snap.

Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/librbd/api/Group.cc
src/tools/rbd/action/Group.cc

index f5f90bfd5729ffc98b0a32bfee35216de63d3a5d..4f47562051527451f94b722c8b89602a8b4509ea 100644 (file)
@@ -731,7 +731,7 @@ int Group<I>::snap_create(librados::IoCtx& group_ioctx,
       ldout(cct, 1) << "Failed to create io context for image" << dendl;
     }
 
-    ldout(cct, 20) << "Openning image with id" << image.spec.image_id << dendl;
+    ldout(cct, 20) << "Opening image with id " << image.spec.image_id << dendl;
 
     librbd::ImageCtx* image_ctx = new ImageCtx("", image.spec.image_id.c_str(),
                                               nullptr, image_io_ctx, false);
index 88badde20640b35d5bfc2aee8ed269baac2fc343..4cecce6c6442d872a0406fbd127b15632cd8dab7 100644 (file)
@@ -392,8 +392,13 @@ int execute_group_snap_create(const po::variables_map &vm,
 
   librbd::RBD rbd;
   r = rbd.group_snap_remove(io_ctx, group_name.c_str(), snap_name.c_str());
+  if (r < 0) {
+    std::cerr << "rbd: failed to remove group snapshot: "
+              << cpp_strerror(r) << std::endl;
+    return r;
+  }
 
-  return r;
+  return 0;
 }
 
 int execute_group_snap_rename(const po::variables_map &vm,
@@ -426,6 +431,12 @@ int execute_group_snap_rename(const po::variables_map &vm,
     return -EINVAL;
   }
 
+  r = utils::validate_snapshot_name(at::ARGUMENT_MODIFIER_DEST, dest_snap_name,
+                                    utils::SNAPSHOT_PRESENCE_REQUIRED,
+                                    utils::SPEC_VALIDATION_SNAP);
+  if (r < 0) {
+    return r;
+  }
   librados::Rados rados;
   librados::IoCtx io_ctx;
   r = utils::init(pool_name, &rados, &io_ctx);
@@ -438,7 +449,8 @@ int execute_group_snap_rename(const po::variables_map &vm,
                             source_snap_name.c_str(), dest_snap_name.c_str());
 
   if (r < 0) {
-    std::cerr << "rbd: failed to rename snapshot" << std::endl;
+    std::cerr << "rbd: failed to rename group snapshot: "
+              << cpp_strerror(r) << std::endl;
     return r;
   }