From: Ilya Dryomov Date: Sun, 20 Feb 2022 16:11:28 +0000 (+0100) Subject: rbd-mirror: turn m_on_stop_finish into a list of Contexts X-Git-Tag: v18.0.0~1352^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4ad31cd0583ebb695a9d84a35b9fc20ad9ec8585;p=ceph.git rbd-mirror: turn m_on_stop_finish into a list of Contexts Signed-off-by: Ilya Dryomov --- diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index b6f9b1f112656..6e16c02c700d9 100644 --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@ -244,7 +244,7 @@ ImageReplayer::~ImageReplayer() unregister_admin_socket_hook(); ceph_assert(m_state_builder == nullptr); ceph_assert(m_on_start_finish == nullptr); - ceph_assert(m_on_stop_finish == nullptr); + ceph_assert(m_on_stop_contexts.empty()); ceph_assert(m_bootstrap_request == nullptr); ceph_assert(m_update_status_task == nullptr); delete m_replayer_listener; @@ -316,7 +316,7 @@ void ImageReplayer::start(Context *on_finish, bool manual, bool restart) ceph_assert(m_on_start_finish == nullptr); m_on_start_finish = on_finish; } - ceph_assert(m_on_stop_finish == nullptr); + ceph_assert(m_on_stop_contexts.empty()); } } @@ -548,8 +548,10 @@ void ImageReplayer::stop(Context *on_finish, bool manual, bool restart) shut_down_replay = true; } - ceph_assert(m_on_stop_finish == nullptr); - std::swap(m_on_stop_finish, on_finish); + ceph_assert(m_on_stop_contexts.empty()); + if (on_finish != nullptr) { + m_on_stop_contexts.push_back(on_finish); + } m_stop_requested = true; m_manual_stop = manual; } @@ -980,11 +982,11 @@ void ImageReplayer::handle_shut_down(int r) { dout(10) << "stop complete" << dendl; Context *on_start = nullptr; - Context *on_stop = nullptr; + Contexts on_stop_contexts; { std::lock_guard locker{m_lock}; std::swap(on_start, m_on_start_finish); - std::swap(on_stop, m_on_stop_finish); + on_stop_contexts = std::move(m_on_stop_contexts); m_stop_requested = false; ceph_assert(m_state == STATE_STOPPING); m_state = STATE_STOPPED; @@ -995,9 +997,9 @@ void ImageReplayer::handle_shut_down(int r) { on_start->complete(r); r = 0; } - if (on_stop != nullptr) { - dout(10) << "on stop finish complete, r=" << r << dendl; - on_stop->complete(r); + for (auto ctx : on_stop_contexts) { + dout(10) << "on stop finish " << ctx << " complete, r=" << r << dendl; + ctx->complete(r); } } diff --git a/src/tools/rbd_mirror/ImageReplayer.h b/src/tools/rbd_mirror/ImageReplayer.h index d9fca44182ca8..432fdf225750c 100644 --- a/src/tools/rbd_mirror/ImageReplayer.h +++ b/src/tools/rbd_mirror/ImageReplayer.h @@ -148,6 +148,7 @@ protected: private: typedef std::set> Peers; + typedef std::list Contexts; enum State { STATE_UNKNOWN, @@ -214,7 +215,7 @@ private: ReplayerListener* m_replayer_listener = nullptr; Context *m_on_start_finish = nullptr; - Context *m_on_stop_finish = nullptr; + Contexts m_on_stop_contexts; bool m_stop_requested = false; bool m_manual_stop = false;