From: Jason Dillaman Date: Tue, 2 Jan 2018 15:09:35 +0000 (-0500) Subject: librbd: switching to pool mode shouldn't affect existing mirrored images X-Git-Tag: v13.0.2~662^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76d80bb71f1ff2a090de80771d2ce8ea4d98f75d;p=ceph-ci.git librbd: switching to pool mode shouldn't affect existing mirrored images Previously, non-primary images within a pool would prevent the switch from image-mode to pool-mode mirroring. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/mirror/EnableRequest.cc b/src/librbd/mirror/EnableRequest.cc index 3a94096eb79..a3ab8ad5c19 100644 --- a/src/librbd/mirror/EnableRequest.cc +++ b/src/librbd/mirror/EnableRequest.cc @@ -33,42 +33,7 @@ EnableRequest::EnableRequest(librados::IoCtx &io_ctx, template void EnableRequest::send() { - send_get_tag_owner(); -} - -template -void EnableRequest::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; - 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 -Context *EnableRequest::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 @@ -123,6 +88,41 @@ Context *EnableRequest::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 +void EnableRequest::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; + 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 +Context *EnableRequest::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; } diff --git a/src/librbd/mirror/EnableRequest.h b/src/librbd/mirror/EnableRequest.h index 3b39465d1e5..bba353e2ceb 100644 --- a/src/librbd/mirror/EnableRequest.h +++ b/src/librbd/mirror/EnableRequest.h @@ -44,12 +44,12 @@ private: * * | * 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);