]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: permit cross-namespace when using clone v2
authorJason Dillaman <dillaman@redhat.com>
Mon, 20 Aug 2018 20:33:20 +0000 (16:33 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 19 Sep 2018 12:05:29 +0000 (08:05 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/image/CloneRequest.cc
src/tools/rbd/action/Clone.cc

index 936d002592932734e7302fa75124d35031dace70..97fd849f5d05592c1b1f1ad128a6cf2b072b3c00 100644 (file)
@@ -112,6 +112,13 @@ void CloneRequest<I>::validate_options() {
     }
   }
 
+  if (m_clone_format == 1 &&
+      m_parent_io_ctx.get_namespace() != m_ioctx.get_namespace()) {
+    ldout(m_cct, 1) << "clone v2 required for cross-namespace clones" << dendl;
+    complete(-EXDEV);
+    return;
+  }
+
   open_parent();
 }
 
index e668590725b3af719b0d0388ef9b163554b1367f..6406c957e49804398a7051c165f9e83571ca6b41 100644 (file)
@@ -63,12 +63,6 @@ int execute(const po::variables_map &vm,
   }
   opts.set(RBD_IMAGE_OPTION_FORMAT, static_cast<uint64_t>(2));
 
-  // TODO clones across namespaces not yet supported
-  if (namespace_name != dst_namespace_name) {
-    std::cerr << "rbd: clones across namespaces is not supported." << std::endl;
-    return -EINVAL;
-  }
-
   librados::Rados rados;
   librados::IoCtx io_ctx;
   r = utils::init(pool_name, namespace_name, &rados, &io_ctx);
@@ -85,7 +79,11 @@ int execute(const po::variables_map &vm,
   librbd::RBD rbd;
   r = do_clone(rbd, io_ctx, image_name.c_str(), snap_name.c_str(), dst_io_ctx,
                dst_image_name.c_str(), opts);
-  if (r < 0) {
+  if (r == -EXDEV) {
+    std::cerr << "rbd: clone v2 required for cross-namespace clones."
+              << std::endl;
+    return r;
+  } else if (r < 0) {
     std::cerr << "rbd: clone error: " << cpp_strerror(r) << std::endl;
     return r;
   }