]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: switching to pool mode shouldn't affect existing mirrored images
authorJason Dillaman <dillaman@redhat.com>
Tue, 2 Jan 2018 15:09:35 +0000 (10:09 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 2 Jan 2018 15:11:56 +0000 (10:11 -0500)
Previously, non-primary images within a pool would prevent the switch from
image-mode to pool-mode mirroring.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/mirror/EnableRequest.cc
src/librbd/mirror/EnableRequest.h

index 3a94096eb79f8eacb828fbe3d947fb4cc94a8abf..a3ab8ad5c19605f3df15ce0565d369345e93a258 100644 (file)
@@ -33,42 +33,7 @@ EnableRequest<I>::EnableRequest(librados::IoCtx &io_ctx,
 
 template <typename I>
 void EnableRequest<I>::send() {
-  send_get_tag_owner();
-}
-
-template <typename I>
-void EnableRequest<I>::send_get_tag_owner() {
-  if (!m_non_primary_global_image_id.empty()) {
-    return
-    send_get_mirror_image();
-  }
-  ldout(m_cct, 10) << this << " " << __func__ << dendl;
-
-  using klass = EnableRequest<I>;
-  Context *ctx = create_context_callback<
-      klass, &klass::handle_get_tag_owner>(this);
-  librbd::Journal<>::is_tag_owner(m_io_ctx, m_image_id, &m_is_primary,
-                                  m_op_work_queue, ctx);
-}
-
-template <typename I>
-Context *EnableRequest<I>::handle_get_tag_owner(int *result) {
-  ldout(m_cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
-
-  if (*result < 0) {
-    lderr(m_cct) << "failed to check tag ownership: " << cpp_strerror(*result)
-                 << dendl;
-    return m_on_finish;
-  }
-
-  if (!m_is_primary) {
-    lderr(m_cct) << "last journal tag not owned by local cluster" << dendl;
-    *result = -EINVAL;
-    return m_on_finish;
-  }
-
   send_get_mirror_image();
-  return nullptr;
 }
 
 template <typename I>
@@ -123,6 +88,41 @@ Context *EnableRequest<I>::handle_get_mirror_image(int *result) {
     m_mirror_image.global_image_id = m_non_primary_global_image_id;
   }
 
+  send_get_tag_owner();
+  return nullptr;
+}
+
+template <typename I>
+void EnableRequest<I>::send_get_tag_owner() {
+  if (!m_non_primary_global_image_id.empty()) {
+    send_set_mirror_image();
+    return;
+  }
+  ldout(m_cct, 10) << this << " " << __func__ << dendl;
+
+  using klass = EnableRequest<I>;
+  Context *ctx = create_context_callback<
+      klass, &klass::handle_get_tag_owner>(this);
+  librbd::Journal<>::is_tag_owner(m_io_ctx, m_image_id, &m_is_primary,
+                                  m_op_work_queue, ctx);
+}
+
+template <typename I>
+Context *EnableRequest<I>::handle_get_tag_owner(int *result) {
+  ldout(m_cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(m_cct) << "failed to check tag ownership: " << cpp_strerror(*result)
+                 << dendl;
+    return m_on_finish;
+  }
+
+  if (!m_is_primary) {
+    lderr(m_cct) << "last journal tag not owned by local cluster" << dendl;
+    *result = -EINVAL;
+    return m_on_finish;
+  }
+
   send_set_mirror_image();
   return nullptr;
 }
index 3b39465d1e5cc91f84bd8efbb078975569978ae5..bba353e2ceb27575b779ef8a06b989f919840966 100644 (file)
@@ -44,12 +44,12 @@ private:
    * <start>
    *    |
    *    v
-   * GET_TAG_OWNER  * * * * * * * *
-   *    |                         *
-   *    v                         *
    * GET_MIRROR_IMAGE * * * * * * *
    *    |                         * (on error)
    *    v                         *
+   * GET_TAG_OWNER  * * * * * * * *
+   *    |                         *
+   *    v                         *
    * SET_MIRROR_IMAGE * * * * * * *
    *    |                         *
    *    v                         *
@@ -76,12 +76,12 @@ private:
   bufferlist m_out_bl;
   cls::rbd::MirrorImage m_mirror_image;
 
-  void send_get_tag_owner();
-  Context *handle_get_tag_owner(int *result);
-
   void send_get_mirror_image();
   Context *handle_get_mirror_image(int *result);
 
+  void send_get_tag_owner();
+  Context *handle_get_tag_owner(int *result);
+
   void send_set_mirror_image();
   Context *handle_set_mirror_image(int *result);