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
(cherry picked from commit
a1e0d623d5026baec9d1e6ed83201c3fb326fc10)
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();
+ 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>
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();
}
* <start>
* |
* v
- * REFRESH
- * |
- * v
* GET_MIRROR_IMAGE
* |
* v
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);