]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: track bootstrap state within image status
authorJason Dillaman <dillaman@redhat.com>
Wed, 18 May 2016 03:31:02 +0000 (23:31 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 20 May 2016 13:01:53 +0000 (09:01 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit e5dd97b4bf4a993911febf34dce90470a2a91d59)

src/tools/rbd_mirror/ImageReplayer.cc
src/tools/rbd_mirror/ImageReplayer.h

index 4ba7e9878c0d19e1f1f49fd0dbf248f217a9c6e9..443c180d27e7ed557dbae994db4785e1e683b48e 100644 (file)
@@ -372,8 +372,6 @@ void ImageReplayer<I>::bootstrap() {
   dout(20) << "bootstrap params: "
           << "local_image_name=" << m_local_image_name << dendl;
 
-  update_mirror_image_status();
-
   // TODO: add a new bootstrap state and support canceling
   Context *ctx = create_context_callback<
     ImageReplayer, &ImageReplayer<I>::handle_bootstrap>(this);
@@ -384,13 +382,25 @@ void ImageReplayer<I>::bootstrap() {
     m_threads->work_queue, m_threads->timer, &m_threads->timer_lock,
     m_local_mirror_uuid, m_remote_mirror_uuid, m_remote_journaler,
     &m_client_meta, ctx, &m_progress_cxt);
+
+  {
+    Mutex::Locker locker(m_lock);
+    m_bootstrap_request = request;
+  }
+
   request->send();
+  update_mirror_image_status();
 }
 
 template <typename I>
 void ImageReplayer<I>::handle_bootstrap(int r) {
   dout(20) << "r=" << r << dendl;
 
+  {
+    Mutex::Locker locker(m_lock);
+    m_bootstrap_request = nullptr;
+  }
+
   if (r == -EREMOTEIO) {
     dout(5) << "remote image is non-primary or local image is primary" << dendl;
     on_start_fail_start(0, "remote image is non-primary or local image is primary");
@@ -1068,8 +1078,7 @@ void ImageReplayer<I>::update_mirror_image_status(bool final,
 
     switch (m_state) {
     case STATE_STARTING:
-      // TODO: a better way to detect syncing state.
-      if (!m_asok_hook) {
+      if (m_bootstrap_request != nullptr) {
        status.state = cls::rbd::MIRROR_IMAGE_STATUS_STATE_SYNCING;
        status.description = m_state_desc.empty() ? "syncing" : m_state_desc;
       } else {
index af8133d92be0fb1acb0698f617c47b0a578f1c55..42ad9f92a25e416455a910f997162d05097be313 100644 (file)
@@ -40,6 +40,7 @@ namespace mirror {
 
 struct Threads;
 
+namespace image_replayer { template <typename> class BootstrapRequest; }
 namespace image_replayer { template <typename> class ReplayStatusFormatter; }
 
 /**
@@ -231,6 +232,8 @@ private:
 
   AdminSocketHook *m_asok_hook = nullptr;
 
+  image_replayer::BootstrapRequest<ImageCtxT> *m_bootstrap_request = nullptr;
+
   librbd::journal::MirrorPeerClientMeta m_client_meta;
 
   ReplayEntry m_replay_entry;