]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: properly close image on aborted open attempt
authorJason Dillaman <dillaman@redhat.com>
Wed, 11 Nov 2020 02:03:39 +0000 (21:03 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 17 Nov 2020 01:25:16 +0000 (20:25 -0500)
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 <dillaman@redhat.com>
src/librbd/migration/OpenSourceImageRequest.cc

index 499525395d3cb730845647a8dab4c5a0aa510275..fc574ef7498443dadaec74a74bc4fa6db48153d2 100644 (file)
@@ -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<I>::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<I>::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<I>::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;
 }