]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: avoid async callback on image ctx open request
authorJason Dillaman <dillaman@redhat.com>
Wed, 2 Dec 2020 02:26:54 +0000 (21:26 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 2 Dec 2020 03:34:34 +0000 (22:34 -0500)
If the ImageState::open call fails, we cannot have the callback be
asynchronously dispatched via the now deleted ImageCtx object.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageState.cc
src/librbd/migration/NativeFormat.cc

index ab63b69bddaeb995e267dd17c5436db532b6c6fa..a81a8373dbd61cbe47fa37fc8d6837bf62c0168c 100644 (file)
@@ -808,6 +808,11 @@ void ImageState<I>::complete_action_unlock(State next_state, int r) {
     TaskFinisherSingleton::get_singleton(m_image_ctx->cct).queue(ctx, r);
   } else {
     for (auto ctx : action_contexts.second) {
+      if (next_state == STATE_OPEN) {
+        // we couldn't originally wrap the open callback w/ an async wrapper in
+        // case the image failed to open
+        ctx = create_async_context_callback(*m_image_ctx, ctx);
+      }
       ctx->complete(r);
     }
 
@@ -828,9 +833,8 @@ void ImageState<I>::send_open_unlock() {
 
   m_state = STATE_OPENING;
 
-  Context *ctx = create_async_context_callback(
-    *m_image_ctx, create_context_callback<
-      ImageState<I>, &ImageState<I>::handle_open>(this));
+  Context *ctx = create_context_callback<
+    ImageState<I>, &ImageState<I>::handle_open>(this);
   image::OpenRequest<I> *req = image::OpenRequest<I>::create(
     m_image_ctx, m_open_flags, ctx);
 
index 91846f61d284a762a5830983979bedf47d5d000f..68d1ac864a357a4c4ec587a44288802c9ee5ab72 100644 (file)
@@ -153,8 +153,7 @@ void NativeFormat<I>::open(Context* on_finish) {
   }
 
   // open the source RBD image
-  auto ctx = util::create_async_context_callback(*m_image_ctx, on_finish);
-  m_image_ctx->state->open(flags, ctx);
+  m_image_ctx->state->open(flags, on_finish);
 }
 
 template <typename I>