From 8ad19af30a487422be8a743289bd929e5e71f280 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 15 Oct 2020 10:21:22 -0400 Subject: [PATCH] librbd: refresh parent now utilizes migration open source request The migration open source image state machine will handle how to initialize the source ImageCtx depending on the format and protocol utilized for the source image. Signed-off-by: Jason Dillaman --- src/librbd/image/RefreshParentRequest.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index 6689b137b05f6..27cc99f529ebc 100644 --- a/src/librbd/image/RefreshParentRequest.cc +++ b/src/librbd/image/RefreshParentRequest.cc @@ -10,6 +10,7 @@ #include "librbd/Utils.h" #include "librbd/asio/ContextWQ.h" #include "librbd/io/ObjectDispatcherInterface.h" +#include "librbd/migration/OpenSourceImageRequest.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -112,6 +113,18 @@ void RefreshParentRequest::send_open_parent() { CephContext *cct = m_child_image_ctx.cct; ldout(cct, 10) << this << " " << __func__ << dendl; + if (!m_migration_info.empty()) { + auto ctx = create_async_context_callback( + m_child_image_ctx, create_context_callback< + RefreshParentRequest, + &RefreshParentRequest::handle_open_parent, false>(this)); + auto req = migration::OpenSourceImageRequest::create( + &m_child_image_ctx, m_parent_md.spec.snap_id, m_migration_info, + &m_parent_image_ctx, ctx); + req->send(); + return; + } + librados::IoCtx parent_io_ctx; int r = util::create_ioctx(m_child_image_ctx.md_ctx, "parent image", m_parent_md.spec.pool_id, @@ -121,14 +134,7 @@ void RefreshParentRequest::send_open_parent() { return; } - std::string image_name; - uint64_t flags = 0; - if (!m_migration_info.empty() && !m_migration_info.image_name.empty()) { - image_name = m_migration_info.image_name; - flags |= OPEN_FLAG_OLD_FORMAT; - } - - m_parent_image_ctx = new I(image_name, m_parent_md.spec.image_id, + m_parent_image_ctx = new I("", m_parent_md.spec.image_id, m_parent_md.spec.snap_id, parent_io_ctx, true); m_parent_image_ctx->child = &m_child_image_ctx; @@ -143,7 +149,7 @@ void RefreshParentRequest::send_open_parent() { m_child_image_ctx, create_context_callback< RefreshParentRequest, &RefreshParentRequest::handle_open_parent, false>(this)); - m_parent_image_ctx->state->open(flags, ctx); + m_parent_image_ctx->state->open(0U, ctx); } template -- 2.39.5