]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: permit creation of clones against non-primary images
authorJason Dillaman <dillaman@redhat.com>
Tue, 19 Dec 2017 15:23:44 +0000 (10:23 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 2 Jan 2018 15:11:56 +0000 (10:11 -0500)
Fixes: http://tracker.ceph.com/issues/18480
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
qa/workunits/rbd/rbd_mirror.sh
src/librbd/image/CloneRequest.cc
src/librbd/image/CloneRequest.h

index 3e7f844faeaf948e3bd73d1c15ec4bd1b52a26db..233c06dd3f377c4ed44dafae6ecf0cbf173380e9 100755 (executable)
@@ -229,8 +229,7 @@ wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${clone_image}
 wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' 'master_position'
 compare_images ${POOL} ${clone_image}
 
-expect_failure "is non-primary" clone_image ${CLUSTER1} ${PARENT_POOL} \
-    ${parent_image} ${parent_snap} ${POOL} ${clone_image}1
+clone_image ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image}1
 
 testlog "TEST: data pool"
 dp_image=test_data_pool
index a1c30c187db52fdc43a2293f221269afa76c1c9f..5ececb2c8c684e1a2406a4e714843071ae95dd5f 100644 (file)
@@ -7,7 +7,6 @@
 #include "common/errno.h"
 #include "include/assert.h"
 #include "librbd/ImageState.h"
-#include "librbd/Journal.h"
 #include "librbd/image/CloneRequest.h"
 #include "librbd/image/CreateRequest.h"
 #include "librbd/image/RemoveRequest.h"
@@ -122,36 +121,6 @@ void CloneRequest<I>::send_validate_parent() {
     return complete(-EINVAL);
   }
 
-  if ((m_p_features & RBD_FEATURE_JOURNALING) != 0) {
-    m_force_non_primary = !m_non_primary_global_image_id.empty();
-    using klass = CloneRequest<I>;
-    Context *ctx = create_context_callback<
-       klass, &klass::handle_validate_parent>(this);
-
-    Journal<I>::is_tag_owner(m_p_imctx, &m_is_primary, ctx);
-    return;
-  }
-
-  send_validate_child();
-}
-
-template <typename I>
-void CloneRequest<I>::handle_validate_parent(int r) {
-  ldout(m_cct, 20) << this << " " << __func__ << " r=" << r << dendl;
-
-  if (r < 0) {
-    lderr(m_cct) << "failed to determine tag ownership: " << cpp_strerror(r)
-              << dendl;
-    return complete(r);
-  }
-
-  if ((m_p_features & RBD_FEATURE_JOURNALING) != 0) {
-    if (!m_is_primary && !m_force_non_primary) {
-      lderr(m_cct) << "parent is non-primary mirrored image" << dendl;
-      return complete(-EINVAL);
-    }
-  }
-
   send_validate_child();
 }
 
@@ -464,7 +433,8 @@ void CloneRequest<I>::send_enable_mirror() {
   ldout(m_cct, 20) << this << " " << __func__ << dendl;
 
   using klass = CloneRequest<I>;
-  Context *ctx = create_context_callback<klass, &klass::handle_enable_mirror>(this);
+  Context *ctx = create_context_callback<
+    klass, &klass::handle_enable_mirror>(this);
 
   mirror::EnableRequest<I> *req = mirror::EnableRequest<I>::create(
     m_imctx->md_ctx, m_id, m_non_primary_global_image_id,
index 01d7750c39e851e58e874381138dc8a8d5e0bc3a..851a2021e16e9bb2e59bf6db7693ebaf2bc6b607 100644 (file)
@@ -18,16 +18,23 @@ namespace image {
 template <typename ImageCtxT = ImageCtx>
 class CloneRequest {
 public:
-  static CloneRequest *create(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
-                             const std::string &c_id, ImageOptions c_options,
+  static CloneRequest *create(ImageCtxT *p_imctx, IoCtx &c_ioctx,
+                              const std::string &c_name,
+                              const std::string &c_id, ImageOptions c_options,
                              const std::string &non_primary_global_image_id,
                              const std::string &primary_mirror_uuid,
                              ContextWQ *op_work_queue, Context *on_finish) {
     return new CloneRequest(p_imctx, c_ioctx, c_name, c_id, c_options,
-                             non_primary_global_image_id, primary_mirror_uuid,
-                             op_work_queue, on_finish);
+                            non_primary_global_image_id, primary_mirror_uuid,
+                            op_work_queue, on_finish);
   }
 
+  CloneRequest(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
+               const std::string &c_id, ImageOptions c_options,
+               const std::string &non_primary_global_image_id,
+               const std::string &primary_mirror_uuid,
+               ContextWQ *op_work_queue, Context *on_finish);
+
   void send();
 private:
   /**
@@ -77,13 +84,6 @@ private:
    * @endverbatim
    */
 
-  CloneRequest(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
-                             const std::string &c_id,
-                             ImageOptions c_options,
-                             const std::string &non_primary_global_image_id,
-                             const std::string &primary_mirror_uuid,
-                             ContextWQ *op_work_queue, Context *on_finish);
-
   ImageCtxT *m_p_imctx;
   IoCtx &m_ioctx;
   std::string m_name;
@@ -107,13 +107,10 @@ private:
   bufferlist m_out_bl;
   uint64_t m_size;
   int m_r_saved = 0;
-  bool m_is_primary;
-  bool m_force_non_primary;
 
   void validate_options();
 
   void send_validate_parent();
-  void handle_validate_parent(int r);
 
   void send_validate_child();
   void handle_validate_child(int r);