From c04bd3df46d1f90901bde4313de64a7db8cf1ef1 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Fri, 25 May 2018 16:35:02 +0300 Subject: [PATCH] librbd: use 'open snap by id' in refresh parent request Signed-off-by: Mykola Golub --- src/librbd/image/RefreshParentRequest.cc | 43 ++---------------------- src/librbd/image/RefreshParentRequest.h | 14 +++----- 2 files changed, 6 insertions(+), 51 deletions(-) diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index 5bb00a6683470..5c55f2fa720ef 100644 --- a/src/librbd/image/RefreshParentRequest.cc +++ b/src/librbd/image/RefreshParentRequest.cc @@ -10,7 +10,6 @@ #include "librbd/Utils.h" #include "librbd/image/CloseRequest.h" #include "librbd/image/OpenRequest.h" -#include "librbd/image/SetSnapRequest.h" #include "librbd/io/ObjectDispatcher.h" #define dout_subsys ceph_subsys_rbd @@ -127,8 +126,8 @@ void RefreshParentRequest::send_open_parent() { flags |= OPEN_FLAG_OLD_FORMAT; } - m_parent_image_ctx = new I(image_name, m_parent_md.spec.image_id, nullptr, - parent_io_ctx, true); + m_parent_image_ctx = new I(image_name, 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; // set rados flags for reading the parent image @@ -159,44 +158,6 @@ Context *RefreshParentRequest::handle_open_parent(int *result) { // image already closed by open state machine delete m_parent_image_ctx; m_parent_image_ctx = nullptr; - - return m_on_finish; - } - - if (m_parent_md.spec.snap_id == CEPH_NOSNAP) { - return m_on_finish; - } - - send_set_parent_snap(); - return nullptr; -} - -template -void RefreshParentRequest::send_set_parent_snap() { - assert(m_parent_md.spec.snap_id != CEPH_NOSNAP); - - CephContext *cct = m_child_image_ctx.cct; - ldout(cct, 10) << this << " " << __func__ << dendl; - - using klass = RefreshParentRequest; - Context *ctx = create_context_callback< - klass, &klass::handle_set_parent_snap, false>(this); - SetSnapRequest *req = SetSnapRequest::create( - *m_parent_image_ctx, m_parent_md.spec.snap_id, ctx); - req->send(); -} - -template -Context *RefreshParentRequest::handle_set_parent_snap(int *result) { - CephContext *cct = m_child_image_ctx.cct; - ldout(cct, 10) << this << " " << __func__ << " r=" << *result << dendl; - - save_result(result); - if (*result < 0) { - lderr(cct) << "failed to set parent snapshot: " << cpp_strerror(*result) - << dendl; - send_close_parent(); - return nullptr; } return m_on_finish; diff --git a/src/librbd/image/RefreshParentRequest.h b/src/librbd/image/RefreshParentRequest.h index aeedbf88c69f0..39abc1b789c7d 100644 --- a/src/librbd/image/RefreshParentRequest.h +++ b/src/librbd/image/RefreshParentRequest.h @@ -43,13 +43,10 @@ private: * | (open required) * |----------------> OPEN_PARENT * * * * * * * * * * * * * * * * | | * - * | v * - * | SET_PARENT_SNAP * * * * * * * - * | | * * - * | v * (on error) * - * \----------------> * * - * | * * - * | (close required) v * + * | v (on error) * + * \----------------> * + * | * + * | (close required) * * |-----------------> CLOSE_PARENT * * | | * * | v * @@ -87,9 +84,6 @@ private: void send_open_parent(); Context *handle_open_parent(int *result); - void send_set_parent_snap(); - Context *handle_set_parent_snap(int *result); - void send_close_parent(); Context *handle_close_parent(int *result); -- 2.39.5