]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
api/Mirror: make it more understandable when adding peer returns error 16313/head
authorsongweibin <song.weibin@zte.com.cn>
Thu, 13 Jul 2017 06:41:04 +0000 (14:41 +0800)
committersongweibin <song.weibin@zte.com.cn>
Tue, 18 Jul 2017 05:27:11 +0000 (13:27 +0800)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/tools/rbd/action/MirrorPool.cc

index 929ac446d02cbeaf87acdf82cbbd7162c58d509a..0090a42060b9716886e73eb57b482ab2ba64e4fc 100644 (file)
@@ -528,10 +528,25 @@ int execute_peer_add(const po::variables_map &vm) {
   if (r < 0) {
     return r;
   }
+  
+  librbd::RBD rbd;
+  rbd_mirror_mode_t mirror_mode;
+  r = rbd.mirror_mode_get(io_ctx, &mirror_mode);
+  if (r < 0) {
+    std::cerr << "rbd: failed to retrieve mirror mode: " 
+              << cpp_strerror(r) << std::endl;
+    return r;
+  }
+  
+  if (mirror_mode == RBD_MIRROR_MODE_DISABLED) {
+    std::cerr << "rbd: failed to add mirror peer: "
+              << "mirroring must be enabled on the pool " 
+              << pool_name << std::endl;
+    return -EINVAL;
+  }
 
   // TODO: temporary restriction to prevent adding multiple peers
   // until rbd-mirror daemon can properly handle the scenario
-  librbd::RBD rbd;
   std::vector<librbd::mirror_peer_t> mirror_peers;
   r = rbd.mirror_peer_list(io_ctx, &mirror_peers);
   if (r < 0) {