]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: stub prepare snapshot replay state machine
authorJason Dillaman <dillaman@redhat.com>
Fri, 31 Jan 2020 04:32:40 +0000 (23:32 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 31 Jan 2020 04:32:40 +0000 (23:32 -0500)
The stub doesn't check for split-brain and it doesn't see
if the image still requires a resync.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/CMakeLists.txt
src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.cc [new file with mode: 0644]
src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.h [new file with mode: 0644]
src/tools/rbd_mirror/image_replayer/snapshot/StateBuilder.cc

index 92aa4662496924a260f228431a3f34ba11101166..5ab5d6c588f3d1a79bd87f16486d76afc89acc8d 100644 (file)
@@ -52,6 +52,7 @@ set(rbd_mirror_internal
   image_replayer/journal/StateBuilder.cc
   image_replayer/journal/SyncPointHandler.cc
   image_replayer/snapshot/CreateLocalImageRequest.cc
+  image_replayer/snapshot/PrepareReplayRequest.cc
   image_replayer/snapshot/StateBuilder.cc
   image_sync/SyncPointCreateRequest.cc
   image_sync/SyncPointPruneRequest.cc
diff --git a/src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.cc b/src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.cc
new file mode 100644 (file)
index 0000000..38340de
--- /dev/null
@@ -0,0 +1,39 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "PrepareReplayRequest.h"
+#include "common/debug.h"
+#include "common/dout.h"
+#include "common/errno.h"
+#include "librbd/ImageCtx.h"
+#include "librbd/Utils.h"
+#include "tools/rbd_mirror/ProgressContext.h"
+#include "tools/rbd_mirror/image_replayer/snapshot/StateBuilder.h"
+
+#define dout_context g_ceph_context
+#define dout_subsys ceph_subsys_rbd_mirror
+#undef dout_prefix
+#define dout_prefix *_dout << "rbd::mirror::image_replayer::snapshot::" \
+                           << "PrepareReplayRequest: " << this << " " \
+                           << __func__ << ": "
+
+namespace rbd {
+namespace mirror {
+namespace image_replayer {
+namespace snapshot {
+
+template <typename I>
+void PrepareReplayRequest<I>::send() {
+  // TODO
+  *m_resync_requested = false;
+  *m_syncing = false;
+
+  finish(0);
+}
+
+} // namespace snapshot
+} // namespace image_replayer
+} // namespace mirror
+} // namespace rbd
+
+template class rbd::mirror::image_replayer::snapshot::PrepareReplayRequest<librbd::ImageCtx>;
diff --git a/src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.h b/src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.h
new file mode 100644 (file)
index 0000000..4cd1f9b
--- /dev/null
@@ -0,0 +1,89 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef RBD_MIRROR_IMAGE_REPLAYER_JOURNAL_PREPARE_REPLAY_REQUEST_H
+#define RBD_MIRROR_IMAGE_REPLAYER_JOURNAL_PREPARE_REPLAY_REQUEST_H
+
+#include "include/int_types.h"
+#include "librbd/mirror/Types.h"
+#include "tools/rbd_mirror/BaseRequest.h"
+#include <list>
+#include <string>
+
+struct Context;
+namespace librbd { struct ImageCtx; }
+
+namespace rbd {
+namespace mirror {
+
+class ProgressContext;
+
+namespace image_replayer {
+namespace snapshot {
+
+template <typename> class StateBuilder;
+
+template <typename ImageCtxT>
+class PrepareReplayRequest : public BaseRequest {
+public:
+  static PrepareReplayRequest* create(
+      const std::string& local_mirror_uuid,
+      librbd::mirror::PromotionState remote_promotion_state,
+      ProgressContext* progress_ctx,
+      StateBuilder<ImageCtxT>* state_builder,
+      bool* resync_requested,
+      bool* syncing,
+      Context* on_finish) {
+    return new PrepareReplayRequest(
+      local_mirror_uuid, remote_promotion_state, progress_ctx, state_builder,
+      resync_requested, syncing, on_finish);
+  }
+
+  PrepareReplayRequest(
+      const std::string& local_mirror_uuid,
+      librbd::mirror::PromotionState remote_promotion_state,
+      ProgressContext* progress_ctx,
+      StateBuilder<ImageCtxT>* state_builder,
+      bool* resync_requested,
+      bool* syncing,
+      Context* on_finish)
+    : BaseRequest(on_finish),
+      m_local_mirror_uuid(local_mirror_uuid),
+      m_remote_promotion_state(remote_promotion_state),
+      m_progress_ctx(progress_ctx),
+      m_state_builder(state_builder),
+      m_resync_requested(resync_requested),
+      m_syncing(syncing) {
+  }
+
+  void send() override;
+
+private:
+  // TODO
+  /**
+   * @verbatim
+   *
+   * <start>
+   *    |
+   *    v
+   * <finish>
+   *
+   * @endverbatim
+   */
+
+  std::string m_local_mirror_uuid;
+  librbd::mirror::PromotionState m_remote_promotion_state;
+  ProgressContext* m_progress_ctx;
+  StateBuilder<ImageCtxT>* m_state_builder;
+  bool* m_resync_requested;
+  bool* m_syncing;
+};
+
+} // namespace snapshot
+} // namespace image_replayer
+} // namespace mirror
+} // namespace rbd
+
+extern template class rbd::mirror::image_replayer::snapshot::PrepareReplayRequest<librbd::ImageCtx>;
+
+#endif // RBD_MIRROR_IMAGE_REPLAYER_JOURNAL_PREPARE_REPLAY_REQUEST_H
index fcaa3c17b268a754e6b43bbd743363a9b79a5171..c52d3a611a1486df2850f264ffc0d79859f18a0d 100644 (file)
@@ -8,6 +8,7 @@
 #include "common/errno.h"
 #include "librbd/ImageCtx.h"
 #include "tools/rbd_mirror/image_replayer/snapshot/CreateLocalImageRequest.h"
+#include "tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.h"
 
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rbd_mirror
@@ -83,9 +84,9 @@ BaseRequest* StateBuilder<I>::create_prepare_replay_request(
     bool* resync_requested,
     bool* syncing,
     Context* on_finish) {
-  // TODO
-  ceph_assert(false);
-  return nullptr;
+  return PrepareReplayRequest<I>::create(
+    local_mirror_uuid, this->remote_promotion_state, progress_ctx, this,
+    resync_requested, syncing, on_finish);
 }
 
 template <typename I>