]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: store remote promotion state within state builder
authorJason Dillaman <dillaman@redhat.com>
Mon, 27 Jan 2020 17:43:51 +0000 (12:43 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 30 Jan 2020 15:26:36 +0000 (10:26 -0500)
This simplifies the factory method for the prepare state since it
no longer needs to be an parameter. It will also permit the removal
of the extra get mirror info call in bootstrap.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/image_replayer/test_mock_BootstrapRequest.cc
src/test/rbd_mirror/image_replayer/test_mock_PrepareRemoteImageRequest.cc
src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc
src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.cc
src/tools/rbd_mirror/image_replayer/StateBuilder.h
src/tools/rbd_mirror/image_replayer/journal/StateBuilder.cc
src/tools/rbd_mirror/image_replayer/journal/StateBuilder.h
src/tools/rbd_mirror/image_replayer/snapshot/StateBuilder.cc
src/tools/rbd_mirror/image_replayer/snapshot/StateBuilder.h

index cb25b351cfc9fdbe84a9f7d369f1dab58ff01aea..c9805f6d6220bd68d3223103a53d402c12a195d0 100644 (file)
@@ -305,9 +305,8 @@ struct StateBuilder<librbd::MockTestImageCtx> {
                             const std::string&,
                             ProgressContext*,
                             Context*));
-  MOCK_METHOD6(create_prepare_replay_request,
+  MOCK_METHOD5(create_prepare_replay_request,
                BaseRequest*(const std::string&,
-                            librbd::mirror::PromotionState,
                             ProgressContext*,
                             bool*, bool*, Context*));
 
@@ -500,8 +499,8 @@ public:
   void expect_prepare_replay(MockStateBuilder& mock_state_builder,
                              bool resync_requested, bool syncing, int r) {
     EXPECT_CALL(mock_state_builder,
-                create_prepare_replay_request(_, _, _, _, _, _))
-      .WillOnce(WithArgs<3, 4, 5>(
+                create_prepare_replay_request(_, _, _, _, _))
+      .WillOnce(WithArgs<2, 3, 4>(
         Invoke([this, &mock_state_builder, resync_requested, syncing, r]
                (bool* resync, bool* sync, Context* ctx) {
           if (r >= 0) {
index ff65fef4c26b7d042cf23429f62323da334c8061..180a6f823c7c93615f7423503e1b89422b8debf7 100644 (file)
@@ -121,6 +121,7 @@ struct StateBuilder<librbd::MockTestImageCtx> {
   std::string local_image_id;
   std::string remote_image_id;
   std::string remote_mirror_uuid;
+  librbd::mirror::PromotionState remote_promotion_state;
 
   virtual ~StateBuilder() {}
 
@@ -285,6 +286,8 @@ TEST_F(TestMockImageReplayerPrepareRemoteImageRequest, Success) {
   ASSERT_TRUE(mock_state_builder != nullptr);
   ASSERT_EQ(std::string("remote image id"),
             mock_journal_state_builder.remote_image_id);
+  ASSERT_EQ(librbd::mirror::PROMOTION_STATE_PRIMARY,
+            mock_journal_state_builder.remote_promotion_state);
   ASSERT_TRUE(mock_journal_state_builder.remote_journaler != nullptr);
   ASSERT_EQ(cls::journal::CLIENT_STATE_DISCONNECTED,
             mock_journal_state_builder.remote_client_state);
@@ -341,6 +344,8 @@ TEST_F(TestMockImageReplayerPrepareRemoteImageRequest, SuccessNotRegistered) {
   ASSERT_TRUE(mock_state_builder != nullptr);
   ASSERT_EQ(std::string("remote image id"),
             mock_journal_state_builder.remote_image_id);
+  ASSERT_EQ(librbd::mirror::PROMOTION_STATE_PRIMARY,
+            mock_journal_state_builder.remote_promotion_state);
   ASSERT_TRUE(mock_journal_state_builder.remote_journaler != nullptr);
   ASSERT_EQ(cls::journal::CLIENT_STATE_CONNECTED,
             mock_journal_state_builder.remote_client_state);
index e783989a28b29b38ac370213bb39cdcbf2df1dac..80d40b60242b5863c7d01997ff0a31ef53f15e8a 100644 (file)
@@ -355,8 +355,7 @@ void BootstrapRequest<I>::prepare_replay() {
   auto ctx = create_context_callback<
     BootstrapRequest<I>, &BootstrapRequest<I>::handle_prepare_replay>(this);
   auto request = (*m_state_builder)->create_prepare_replay_request(
-    m_local_mirror_uuid, m_promotion_state, m_progress_ctx, m_do_resync,
-    &m_syncing, ctx);
+    m_local_mirror_uuid, m_progress_ctx, m_do_resync, &m_syncing, ctx);
   request->send();
 }
 
index dfeb849c5b904512f9824f4c44cb4eee9986b31c..ccb578848ff537b58edbfe3fd32052ce2411db1f 100644 (file)
@@ -218,6 +218,7 @@ void PrepareRemoteImageRequest<I>::finalize_journal_state_builder(
 
   state_builder->remote_mirror_uuid = m_remote_pool_meta.mirror_uuid;
   state_builder->remote_image_id = m_remote_image_id;
+  state_builder->remote_promotion_state = m_promotion_state;
   state_builder->remote_journaler = m_remote_journaler;
   state_builder->remote_client_state = client_state;
   state_builder->remote_client_meta = client_meta;
index ff291617ad840fe93608ea3383b9b25df92811f4..192ffca44e8898f3b6c510bd6a26e1eea3bd698c 100644 (file)
@@ -59,7 +59,6 @@ public:
 
   virtual BaseRequest* create_prepare_replay_request(
       const std::string& local_mirror_uuid,
-      librbd::mirror::PromotionState remote_promotion_state,
       ProgressContext* progress_ctx,
       bool* resync_requested,
       bool* syncing,
@@ -80,6 +79,8 @@ public:
 
   std::string remote_mirror_uuid;
   std::string remote_image_id;
+  librbd::mirror::PromotionState remote_promotion_state =
+    librbd::mirror::PROMOTION_STATE_NON_PRIMARY;
 
 protected:
   image_sync::SyncPointHandler* m_sync_point_handler = nullptr;
index 2b7a463671af0ea03422c9589cc1eb76c6c0d84a..7372475d87078df05b464ea3fb54c927e1ec42a8 100644 (file)
@@ -83,13 +83,12 @@ BaseRequest* StateBuilder<I>::create_local_image_request(
 template <typename I>
 BaseRequest* StateBuilder<I>::create_prepare_replay_request(
     const std::string& local_mirror_uuid,
-    librbd::mirror::PromotionState remote_promotion_state,
     ProgressContext* progress_ctx,
     bool* resync_requested,
     bool* syncing,
     Context* on_finish) {
   return PrepareReplayRequest<I>::create(
-    local_mirror_uuid, remote_promotion_state, progress_ctx, this,
+    local_mirror_uuid, this->remote_promotion_state, progress_ctx, this,
     resync_requested, syncing, on_finish);
 }
 
index c09f2a7f4fdf119eb13bc39a8de1375deec082a3..868260699f2014fb58057204ad4356fc50f146c2 100644 (file)
@@ -52,7 +52,6 @@ public:
 
   BaseRequest* create_prepare_replay_request(
       const std::string& local_mirror_uuid,
-      librbd::mirror::PromotionState remote_promotion_state,
       ProgressContext* progress_ctx,
       bool* resync_requested,
       bool* syncing,
index 82b631a83788a38d48ddbacbe6e6d5af172e1650..018574dec72b2ff86260add6e76c9d0b8880d433 100644 (file)
@@ -71,7 +71,6 @@ BaseRequest* StateBuilder<I>::create_local_image_request(
 template <typename I>
 BaseRequest* StateBuilder<I>::create_prepare_replay_request(
     const std::string& local_mirror_uuid,
-    librbd::mirror::PromotionState remote_promotion_state,
     ProgressContext* progress_ctx,
     bool* resync_requested,
     bool* syncing,
index ff4b12096761be59f8f86edf72426305e5a0ab08..105e3a0134893490fe5c05ee13885fa81d9ce71c 100644 (file)
@@ -46,7 +46,6 @@ public:
 
   BaseRequest* create_prepare_replay_request(
       const std::string& local_mirror_uuid,
-      librbd::mirror::PromotionState remote_promotion_state,
       ProgressContext* progress_ctx,
       bool* resync_requested,
       bool* syncing,