diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index f9ce4f18a89..a44124f3913 100644 --- a/src/librbd/image/RefreshParentRequest.cc +++ b/src/librbd/image/RefreshParentRequest.cc @@ -117,8 +117,9 @@ void RefreshParentRequest::send_open_parent() { } using klass = RefreshParentRequest; - Context *ctx = create_context_callback< - klass, &klass::handle_open_parent, false>(this); + Context *ctx = create_async_context_callback( + m_child_image_ctx, create_context_callback< + klass, &klass::handle_open_parent, false>(this)); OpenRequest *req = OpenRequest::create(m_parent_image_ctx, ctx); req->send(); } @@ -132,8 +133,12 @@ Context *RefreshParentRequest::handle_open_parent(int *result) { if (*result < 0) { lderr(cct) << "failed to open parent image: " << cpp_strerror(*result) << dendl; - send_close_parent(); - return nullptr; + + // image already closed by open state machine + delete m_parent_image_ctx; + m_parent_image_ctx = nullptr; + + return m_on_finish; } send_set_parent_snap(); diff --git a/src/librbd/image/RefreshParentRequest.h b/src/librbd/image/RefreshParentRequest.h index e51d24f48b6..3fe653952c9 100644 --- a/src/librbd/image/RefreshParentRequest.h +++ b/src/librbd/image/RefreshParentRequest.h @@ -38,19 +38,19 @@ private: * * | * | (open required) - * |----------------> OPEN_PARENT * * * * * * * * - * | | * - * | v * (on error) - * | SET_PARENT_SNAP * * * * * * - * | | * - * | v * - * \----------------> * - * | * - * | (close required) v - * |-----------------> CLOSE_PARENT - * | | - * | v - * \-----------------> + * |----------------> OPEN_PARENT * * * * * * * * * * * * * * * + * | | * + * | v * + * | SET_PARENT_SNAP * * * * * * * + * | | * * + * | v * (on error) * + * \----------------> * * + * | * * + * | (close required) v * + * |-----------------> CLOSE_PARENT * + * | | * + * | v * + * \-----------------> < * * * * * * @endverbatim */