]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: don't call refresh from mirror::GetInfoRequest state machine 32900/head
authorMykola Golub <mgolub@suse.com>
Mon, 20 Jan 2020 13:42:47 +0000 (13:42 +0000)
committerNathan Cutler <ncutler@suse.com>
Mon, 27 Jan 2020 15:45:02 +0000 (16:45 +0100)
Fixes: https://tracker.ceph.com/issues/43589
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit da46798ab3f56a639cc7a0b885778e8f75505b53)

Conflicts:
src/librbd/api/Mirror.cc
- C_ImageGetInfo ctor takes only two arguments in nautilus
- nautilus does not have LambdaContext as a class; use FunctionContext
  instead

src/librbd/api/Mirror.cc
src/librbd/mirror/GetInfoRequest.cc
src/librbd/mirror/GetInfoRequest.h

index 92ba3359f8f2092594ff9ee5f14c5eb244bb6c56..4e7b7dc88f5e7e2a270acfb1a2186d3faf33a2df 100644 (file)
@@ -631,11 +631,26 @@ void Mirror<I>::image_get_info(I *ictx, mirror_image_info_t *mirror_image_info,
   CephContext *cct = ictx->cct;
   ldout(cct, 20) << "ictx=" << ictx << dendl;
 
-  auto ctx = new C_ImageGetInfo(mirror_image_info, on_finish);
-  auto req = mirror::GetInfoRequest<I>::create(*ictx, &ctx->mirror_image,
-                                               &ctx->promotion_state,
-                                               ctx);
-  req->send();
+  auto on_refresh = new FunctionContext(
+    [ictx, mirror_image_info, on_finish](int r) {
+      if (r < 0) {
+        lderr(ictx->cct) << "refresh failed: " << cpp_strerror(r) << dendl;
+        on_finish->complete(r);
+        return;
+      }
+
+      auto ctx = new C_ImageGetInfo(mirror_image_info, on_finish);
+      auto req = mirror::GetInfoRequest<I>::create(*ictx, &ctx->mirror_image,
+                                                   &ctx->promotion_state,
+                                                   ctx);
+      req->send();
+    });
+
+  if (ictx->state->is_refresh_required()) {
+    ictx->state->refresh(on_refresh);
+  } else {
+    on_refresh->complete(0);
+  }
 }
 
 template <typename I>
index 1bd692ae3ea160aef0f6a3835b0b9b314aa259ce..460c8cb18598abdcb04699151180773168cd3c42 100644 (file)
@@ -23,35 +23,6 @@ using librbd::util::create_rados_callback;
 
 template <typename I>
 void GetInfoRequest<I>::send() {
-  refresh_image();
-}
-
-template <typename I>
-void GetInfoRequest<I>::refresh_image() {
-  if (!m_image_ctx.state->is_refresh_required()) {
-    get_mirror_image();
-    return;
-  }
-
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << dendl;
-
-  auto ctx = create_context_callback<
-    GetInfoRequest<I>, &GetInfoRequest<I>::handle_refresh_image>(this);
-  m_image_ctx.state->refresh(ctx);
-}
-
-template <typename I>
-void GetInfoRequest<I>::handle_refresh_image(int r) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << "r=" << r << dendl;
-
-  if (r < 0) {
-    lderr(cct) << "failed to refresh image: " << cpp_strerror(r) << dendl;
-    finish(r);
-    return;
-  }
-
   get_mirror_image();
 }
 
index c37ea581836326a0247ff54c137fc609fdb1dde5..db8073c69c957ffb6ffcd4a3c0db6b3e44d5f357 100644 (file)
@@ -43,9 +43,6 @@ private:
    * <start>
    *    |
    *    v
-   * REFRESH
-   *    |
-   *    v
    * GET_MIRROR_IMAGE
    *    |
    *    v
@@ -65,9 +62,6 @@ private:
   bufferlist m_out_bl;
   std::string m_mirror_uuid;
 
-  void refresh_image();
-  void handle_refresh_image(int r);
-
   void get_mirror_image();
   void handle_get_mirror_image(int r);