From: Jason Dillaman Date: Wed, 11 Nov 2020 02:03:39 +0000 (-0500) Subject: librbd/migration: properly close image on aborted open attempt X-Git-Tag: v16.1.0~527^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dad5d304d6bb33e4f48d927c067fd6cad9e72416;p=ceph.git librbd/migration: properly close image on aborted open attempt If the image is attempted to be openned, it can no longer be deleted. Therefore, just close the image on any error that occurs before attempting to open the image. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/migration/OpenSourceImageRequest.cc b/src/librbd/migration/OpenSourceImageRequest.cc index 499525395d3cb..fc574ef749844 100644 --- a/src/librbd/migration/OpenSourceImageRequest.cc +++ b/src/librbd/migration/OpenSourceImageRequest.cc @@ -5,6 +5,7 @@ #include "common/dout.h" #include "common/errno.h" #include "librbd/ImageCtx.h" +#include "librbd/ImageState.h" #include "librbd/Utils.h" #include "librbd/io/ImageDispatcher.h" #include "librbd/migration/ImageDispatch.h" @@ -71,6 +72,7 @@ void OpenSourceImageRequest::open_source() { if (r < 0) { lderr(cct) << "failed to parse migration source-spec:" << cpp_strerror(r) << dendl; + (*m_src_image_ctx)->state->close(); finish(r); return; } @@ -80,6 +82,7 @@ void OpenSourceImageRequest::open_source() { if (r < 0) { lderr(cct) << "failed to build migration format handler: " << cpp_strerror(r) << dendl; + (*m_src_image_ctx)->state->close(); finish(r); return; } @@ -116,9 +119,9 @@ void OpenSourceImageRequest::finish(int r) { ldout(cct, 10) << "r=" << r << dendl; if (r < 0) { - delete *m_src_image_ctx; *m_src_image_ctx = nullptr; } + m_on_finish->complete(r); delete this; }