]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: flush all incomplete in-flight IOs upon image close
authorJason Dillaman <dillaman@redhat.com>
Wed, 26 Aug 2020 23:40:39 +0000 (19:40 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 26 Aug 2020 23:40:39 +0000 (19:40 -0400)
Fixes: https://tracker.ceph.com/issues/46875
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/image/CloseRequest.cc
src/librbd/image/CloseRequest.h
src/librbd/io/QueueImageDispatch.cc

index a5543ff38bd41d76db4b5191090adec766bdd8db..c12cecd52d71000d9c64bb961e821a7fabcec596 100644 (file)
@@ -90,6 +90,34 @@ void CloseRequest<I>::handle_shut_down_update_watchers(int r) {
                << dendl;
   }
 
+  send_flush();
+}
+
+template <typename I>
+void CloseRequest<I>::send_flush() {
+  CephContext *cct = m_image_ctx->cct;
+  ldout(cct, 10) << this << " " << __func__ << dendl;
+
+  std::shared_lock owner_locker{m_image_ctx->owner_lock};
+  auto ctx = create_context_callback<
+    CloseRequest<I>, &CloseRequest<I>::handle_flush>(this);
+  auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx,
+                                                      io::AIO_TYPE_FLUSH);
+  auto req = io::ImageDispatchSpec<I>::create_flush(
+    *m_image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp,
+    io::FLUSH_SOURCE_INTERNAL, {});
+  req->send();
+}
+
+template <typename I>
+void CloseRequest<I>::handle_flush(int r) {
+  CephContext *cct = m_image_ctx->cct;
+  ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
+
+  if (r < 0) {
+    lderr(cct) << "failed to flush IO: " << cpp_strerror(r) << dendl;
+  }
+
   send_shut_down_exclusive_lock();
 }
 
@@ -108,7 +136,7 @@ void CloseRequest<I>::send_shut_down_exclusive_lock() {
   }
 
   if (m_exclusive_lock == nullptr) {
-    send_flush();
+    send_unregister_image_watcher();
     return;
   }
 
@@ -148,33 +176,6 @@ void CloseRequest<I>::handle_shut_down_exclusive_lock(int r) {
   send_unregister_image_watcher();
 }
 
-template <typename I>
-void CloseRequest<I>::send_flush() {
-  CephContext *cct = m_image_ctx->cct;
-  ldout(cct, 10) << this << " " << __func__ << dendl;
-
-  std::shared_lock owner_locker{m_image_ctx->owner_lock};
-  auto ctx = create_context_callback<
-    CloseRequest<I>, &CloseRequest<I>::handle_flush>(this);
-  auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx,
-                                                      io::AIO_TYPE_FLUSH);
-  auto req = io::ImageDispatchSpec<I>::create_flush(
-    *m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp,
-    io::FLUSH_SOURCE_INTERNAL, {});
-  req->send();
-}
-
-template <typename I>
-void CloseRequest<I>::handle_flush(int r) {
-  CephContext *cct = m_image_ctx->cct;
-  ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
-
-  if (r < 0) {
-    lderr(cct) << "failed to flush IO: " << cpp_strerror(r) << dendl;
-  }
-  send_unregister_image_watcher();
-}
-
 template <typename I>
 void CloseRequest<I>::send_unregister_image_watcher() {
   if (m_image_ctx->image_watcher == nullptr) {
index 7f9f0d52ea6ebe2d6a3a1bc6c28f58f9df6312ba..ee298aa9d073bb1e725f0271c5be5b6e8aad7574 100644 (file)
@@ -33,14 +33,15 @@ private:
    * BLOCK_IMAGE_WATCHER (skip if R/O)
    *    |
    *    v
-   * SHUT_DOWN_UPDATE_WATCHERS  . .
-   *    |                         . (exclusive lock disabled)
-   *    v                         v
-   * SHUT_DOWN_EXCLUSIVE_LOCK   FLUSH
-   *    |                         .
-   *    |     . . . . . . . . . . .
-   *    |     .
-   *    v     v
+   * SHUT_DOWN_UPDATE_WATCHERS
+   *    |
+   *    v
+   * FLUSH
+   *    |
+   *    v (skip if disabled)
+   * SHUT_DOWN_EXCLUSIVE_LOCK
+   *    |
+   *    v
    * UNREGISTER_IMAGE_WATCHER (skip if R/O)
    *    |
    *    v
@@ -82,12 +83,12 @@ private:
   void send_shut_down_update_watchers();
   void handle_shut_down_update_watchers(int r);
 
-  void send_shut_down_exclusive_lock();
-  void handle_shut_down_exclusive_lock(int r);
-
   void send_flush();
   void handle_flush(int r);
 
+  void send_shut_down_exclusive_lock();
+  void handle_shut_down_exclusive_lock(int r);
+
   void send_unregister_image_watcher();
   void handle_unregister_image_watcher(int r);
 
index 607d35df3f7f494d69c8ab9efdee2a89ea9cbec1..a07557aa278e91e288248e9e8048a8097e4cdf98 100644 (file)
@@ -107,10 +107,6 @@ bool QueueImageDispatch<I>::flush(
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << "tid=" << tid << dendl;
 
-  if (flush_source != FLUSH_SOURCE_USER) {
-    return false;
-  }
-
   *dispatch_result = DISPATCH_RESULT_CONTINUE;
   m_flush_tracker->flush(on_dispatched);
   return true;