From 1e4d98cdd4c5d671870735823a80e80751ba13ae Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 19 Jul 2016 15:42:27 -0400 Subject: [PATCH] rbd-mirror: fix issues detected when attempting clean shut down Fixed lockdep issue from status update callback and fixed the potential for a stuck status state. Signed-off-by: Jason Dillaman (cherry picked from commit 0275c7ca23b27dc5250cd33f317e2273470a9fe8) --- src/tools/rbd_mirror/ImageReplayer.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index 5de20db2312fd..c5e81876a64fe 100644 --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@ -640,6 +640,7 @@ void ImageReplayer::stop(Context *on_finish, bool manual) { dout(20) << "on_finish=" << on_finish << dendl; + image_replayer::BootstrapRequest *bootstrap_request = nullptr; bool shut_down_replay = false; bool running = true; { @@ -651,7 +652,8 @@ void ImageReplayer::stop(Context *on_finish, bool manual) if (m_state == STATE_STARTING) { dout(20) << "canceling start" << dendl; if (m_bootstrap_request) { - m_bootstrap_request->cancel(); + bootstrap_request = m_bootstrap_request; + bootstrap_request->get(); } } else { dout(20) << "interrupting replay" << dendl; @@ -666,6 +668,12 @@ void ImageReplayer::stop(Context *on_finish, bool manual) } } + // avoid holding lock since bootstrap request will update status + if (bootstrap_request != nullptr) { + bootstrap_request->cancel(); + bootstrap_request->put(); + } + if (!running) { dout(20) << "not running" << dendl; if (on_finish) { @@ -1180,9 +1188,12 @@ void ImageReplayer::send_mirror_status_update(const OptionalState &opt_state) { Context *on_req_finish = new FunctionContext( [this](int r) { + dout(20) << "replay status ready: r=" << r << dendl; if (r >= 0) { - dout(20) << "replay status ready" << dendl; send_mirror_status_update(boost::none); + } else if (r == -EAGAIN) { + // decrement in-flight status update counter + handle_mirror_status_update(r); } }); -- 2.39.5