]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: pass mirror image mode to create image state machine
authorJason Dillaman <dillaman@redhat.com>
Tue, 28 Jan 2020 18:42:39 +0000 (13:42 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 30 Jan 2020 15:26:36 +0000 (10:26 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/image_replayer/journal/test_mock_CreateLocalImageRequest.cc
src/test/rbd_mirror/image_replayer/test_mock_CreateImageRequest.cc
src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc
src/tools/rbd_mirror/image_replayer/CreateImageRequest.h
src/tools/rbd_mirror/image_replayer/journal/CreateLocalImageRequest.cc

index 6fc7580165ec00151975b5f6aa2836a423bd1099..08402c213decf6fc495257bca98ddb5bd8ce8e87 100644 (file)
@@ -69,6 +69,7 @@ struct CreateImageRequest<librbd::MockTestImageCtx> {
                                     const std::string &local_image_name,
                                    const std::string &local_image_id,
                                     librbd::MockTestImageCtx *remote_image_ctx,
+                                    cls::rbd::MirrorImageMode mirror_image_mode,
                                     Context *on_finish) {
     ceph_assert(s_instance != nullptr);
     s_instance->on_finish = on_finish;
index 896aa03e7d795548351514ef7ed78ba6a4816a7e..417c08c96578cb183bc27158cf6d3dff85814063 100644 (file)
@@ -383,7 +383,9 @@ public:
     return new MockCreateImageRequest(mock_threads, m_local_io_ctx,
                                       global_image_id, remote_mirror_uuid,
                                       local_image_name, local_image_id,
-                                      &mock_remote_image_ctx, on_finish);
+                                      &mock_remote_image_ctx,
+                                      cls::rbd::MIRROR_IMAGE_MODE_JOURNAL,
+                                      on_finish);
   }
 
   librbd::ImageCtx *m_remote_image_ctx;
index 23dde23ec9976826822403acf64e21ffa6a31a6b..854f306f5feef8b887f6773ef4dcb2b5cac9d250 100644 (file)
@@ -35,19 +35,22 @@ namespace mirror {
 namespace image_replayer {
 
 template <typename I>
-CreateImageRequest<I>::CreateImageRequest(Threads<I>* threads,
-                                          librados::IoCtx &local_io_ctx,
-                                          const std::string &global_image_id,
-                                          const std::string &remote_mirror_uuid,
-                                          const std::string &local_image_name,
-                                         const std::string &local_image_id,
-                                          I *remote_image_ctx,
-                                          Context *on_finish)
+CreateImageRequest<I>::CreateImageRequest(
+    Threads<I>* threads,
+    librados::IoCtx &local_io_ctx,
+    const std::string &global_image_id,
+    const std::string &remote_mirror_uuid,
+    const std::string &local_image_name,
+    const std::string &local_image_id,
+    I *remote_image_ctx,
+    cls::rbd::MirrorImageMode mirror_image_mode,
+    Context *on_finish)
   : m_threads(threads), m_local_io_ctx(local_io_ctx),
     m_global_image_id(global_image_id),
     m_remote_mirror_uuid(remote_mirror_uuid),
     m_local_image_name(local_image_name), m_local_image_id(local_image_id),
-    m_remote_image_ctx(remote_image_ctx), m_on_finish(on_finish) {
+    m_remote_image_ctx(remote_image_ctx),
+    m_mirror_image_mode(mirror_image_mode), m_on_finish(on_finish) {
 }
 
 template <typename I>
@@ -83,9 +86,9 @@ void CreateImageRequest<I>::create_image() {
 
   auto req = librbd::image::CreateRequest<I>::create(
     config, m_local_io_ctx, m_local_image_name, m_local_image_id,
-    m_remote_image_ctx->size, image_options, false,
-    cls::rbd::MIRROR_IMAGE_MODE_JOURNAL, m_global_image_id,
-    m_remote_mirror_uuid, m_remote_image_ctx->op_work_queue, ctx);
+    m_remote_image_ctx->size, image_options, false, m_mirror_image_mode,
+    m_global_image_id, m_remote_mirror_uuid, m_remote_image_ctx->op_work_queue,
+    ctx);
   req->send();
 }
 
@@ -346,8 +349,8 @@ void CreateImageRequest<I>::clone_image() {
   librbd::image::CloneRequest<I> *req = librbd::image::CloneRequest<I>::create(
     config, m_local_parent_io_ctx, m_local_parent_spec.image_id, snap_name,
     CEPH_NOSNAP, m_local_io_ctx, m_local_image_name, m_local_image_id, opts,
-    cls::rbd::MIRROR_IMAGE_MODE_JOURNAL, m_global_image_id,
-    m_remote_mirror_uuid, m_remote_image_ctx->op_work_queue, ctx);
+    m_mirror_image_mode, m_global_image_id, m_remote_mirror_uuid,
+    m_remote_image_ctx->op_work_queue, ctx);
   req->send();
 }
 
index 0b20da52920a692032e39964393580edf0070141..c8564e6179b6051dae7d697129caa27d38a5765e 100644 (file)
@@ -8,6 +8,7 @@
 #include "include/types.h"
 #include "include/rados/librados.hpp"
 #include "cls/journal/cls_journal_types.h"
+#include "cls/rbd/cls_rbd_types.h"
 #include "librbd/Types.h"
 #include "librbd/journal/TypeTraits.h"
 #include <string>
@@ -35,10 +36,12 @@ public:
                                     const std::string &local_image_name,
                                    const std::string &local_image_id,
                                     ImageCtxT *remote_image_ctx,
+                                    cls::rbd::MirrorImageMode mirror_image_mode,
                                     Context *on_finish) {
     return new CreateImageRequest(threads, local_io_ctx, global_image_id,
                                   remote_mirror_uuid, local_image_name,
-                                  local_image_id, remote_image_ctx, on_finish);
+                                  local_image_id, remote_image_ctx,
+                                  mirror_image_mode, on_finish);
   }
 
   CreateImageRequest(Threads<ImageCtxT> *threads, librados::IoCtx &local_io_ctx,
@@ -47,6 +50,7 @@ public:
                      const std::string &local_image_name,
                     const std::string &local_image_id,
                      ImageCtxT *remote_image_ctx,
+                     cls::rbd::MirrorImageMode mirror_image_mode,
                      Context *on_finish);
 
   void send();
@@ -95,6 +99,7 @@ private:
   std::string m_local_image_name;
   std::string m_local_image_id;
   ImageCtxT *m_remote_image_ctx;
+  cls::rbd::MirrorImageMode m_mirror_image_mode;
   Context *m_on_finish;
 
   librados::IoCtx m_remote_parent_io_ctx;
index 9403108020cc9166f3d1c1fdf3c3977fa1f7a15e..fa8765faf1c89a091e6d0a36d7a21f2cddb78e7d 100644 (file)
@@ -115,7 +115,8 @@ void CreateLocalImageRequest<I>::create_local_image() {
   auto request = CreateImageRequest<I>::create(
     m_threads, m_local_io_ctx, m_global_image_id,
     m_state_builder->remote_mirror_uuid, image_name,
-    m_state_builder->local_image_id, m_remote_image_ctx, ctx);
+    m_state_builder->local_image_id, m_remote_image_ctx,
+    cls::rbd::MIRROR_IMAGE_MODE_JOURNAL, ctx);
   request->send();
 }
 template <typename I>