]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: remove special case for starting AioCompletion ops 28769/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 29 Apr 2019 15:37:37 +0000 (11:37 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 27 Jun 2019 15:00:02 +0000 (11:00 -0400)
All ops can be immediately started now that flush ops won't
accidentally block themselves.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit b5fc7ecaf7a3741d227ab5a9108392813dd03495)

src/librbd/api/DiffIterate.cc
src/librbd/image/CloseRequest.cc
src/librbd/image/RefreshRequest.cc
src/librbd/io/AioCompletion.cc
src/librbd/io/AioCompletion.h
src/librbd/io/ImageRequest.cc
src/librbd/io/ImageRequestWQ.cc
src/librbd/operation/ResizeRequest.cc
src/test/librbd/journal/test_Replay.cc
src/test/rbd_mirror/test_ImageSync.cc

index 0e620cb5adb74c04ea6aceaaa2d251664940e28e..148734b7e50a8eb7e72e40721335fd0dab512500 100644 (file)
@@ -242,8 +242,8 @@ int DiffIterate<I>::diff_iterate(I *ictx,
   C_SaferCond flush_ctx;
   {
     RWLock::RLocker owner_locker(ictx->owner_lock);
-    auto aio_comp = io::AioCompletion::create(&flush_ctx, ictx,
-                                              io::AIO_TYPE_FLUSH);
+    auto aio_comp = io::AioCompletion::create_and_start(&flush_ctx, ictx,
+                                                        io::AIO_TYPE_FLUSH);
     auto req = io::ImageDispatchSpec<I>::create_flush_request(
       *ictx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
     req->send();
index d114c401862b2a82730eff94e0a4dbd97960f0b0..73d671dca74f9f35fdc9d0b37d21d468648ee4fc 100644 (file)
@@ -165,8 +165,8 @@ void CloseRequest<I>::send_flush() {
   RWLock::RLocker 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(ctx, m_image_ctx,
-                                            io::AIO_TYPE_FLUSH);
+  auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx,
+                                                      io::AIO_TYPE_FLUSH);
   auto req = io::ImageDispatchSpec<I>::create_flush_request(
     *m_image_ctx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
   req->send();
index f100e2c04b198488bc1b81b1d78488bb7a156659..664f5b8b793e5f63b9543fcfb52b0cbf473509bd 100644 (file)
@@ -1245,7 +1245,7 @@ Context *RefreshRequest<I>::send_flush_aio() {
     RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
     auto ctx = create_context_callback<
       RefreshRequest<I>, &RefreshRequest<I>::handle_flush_aio>(this);
-    auto aio_comp = io::AioCompletion::create(
+    auto aio_comp = io::AioCompletion::create_and_start(
       ctx, util::get_image_ctx(&m_image_ctx), io::AIO_TYPE_FLUSH);
     auto req = io::ImageDispatchSpec<I>::create_flush_request(
       m_image_ctx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
index c933135d621d78d81e5e5b841bb8f4674279680f..73c58167446a7040caeef91bba053e40d8506510 100644 (file)
@@ -122,20 +122,17 @@ void AioCompletion::init_time(ImageCtx *i, aio_type_t t) {
   }
 }
 
-void AioCompletion::start_op(bool ignore_type) {
+void AioCompletion::start_op() {
   Mutex::Locker locker(lock);
   ceph_assert(ictx != nullptr);
-  ceph_assert(!async_op.started());
 
   if (aio_type == AIO_TYPE_OPEN || aio_type == AIO_TYPE_CLOSE) {
     // no need to track async open/close operations
     return;
   }
 
-  if (state == AIO_STATE_PENDING &&
-      (ignore_type || aio_type != AIO_TYPE_FLUSH)) {
-    async_op.start_op(*ictx);
-  }
+  ceph_assert(!async_op.started());
+  async_op.start_op(*ictx);
 }
 
 void AioCompletion::fail(int r)
index f8a96a8fcaa1ccc6756d8220e77cf4048e301eaf..f3551a0272cc4ce52a9d9f0164658eb9a36548a7 100644 (file)
@@ -87,17 +87,11 @@ struct AioCompletion {
     return comp;
   }
 
-  template <typename T, void (T::*MF)(int) = &T::complete>
-  static AioCompletion *create(T *obj, ImageCtx *image_ctx, aio_type_t type) {
-    AioCompletion *comp = create<T, MF>(obj);
-    comp->init_time(image_ctx, type);
-    return comp;
-  }
-
   template <typename T, void (T::*MF)(int) = &T::complete>
   static AioCompletion *create_and_start(T *obj, ImageCtx *image_ctx,
                                          aio_type_t type) {
-    AioCompletion *comp = create<T, MF>(obj, image_ctx, type);
+    AioCompletion *comp = create<T, MF>(obj);
+    comp->init_time(image_ctx, type);
     comp->start_op();
     return comp;
   }
@@ -127,7 +121,7 @@ struct AioCompletion {
   }
 
   void init_time(ImageCtx *i, aio_type_t t);
-  void start_op(bool ignore_type = false);
+  void start_op();
   void fail(int r);
 
   void complete();
index 2ddc2c3a5459f1c4abce1262bcbbd079f50e2ae7..6cfd83ad16b3d1b76f1e4719a204ebe3649d7f1e 100644 (file)
@@ -143,7 +143,7 @@ template <typename I>
 void ImageRequest<I>::send() {
   I &image_ctx = this->m_image_ctx;
   ceph_assert(m_aio_comp->is_initialized(get_aio_type()));
-  ceph_assert(m_aio_comp->is_started() ^ (get_aio_type() == AIO_TYPE_FLUSH));
+  ceph_assert(m_aio_comp->is_started());
 
   CephContext *cct = image_ctx.cct;
   AioCompletion *aio_comp = this->m_aio_comp;
@@ -639,7 +639,6 @@ void ImageFlushRequest<I>::send_request() {
   }
 
   // ensure all in-flight IOs are settled if non-user flush request
-  aio_comp->start_op(true);
   aio_comp->async_op.flush(ctx);
   aio_comp->put();
 
index 70e6aae9c91c389fc7c90b69fb2a484642d5a21b..32584640d7ddb8e879aa8d76445f53773484a95c 100644 (file)
@@ -29,7 +29,7 @@ namespace {
 
 template <typename I>
 void flush_image(I& image_ctx, Context* on_finish) {
-  auto aio_comp = librbd::io::AioCompletion::create(
+  auto aio_comp = librbd::io::AioCompletion::create_and_start(
     on_finish, util::get_image_ctx(&image_ctx), librbd::io::AIO_TYPE_FLUSH);
   auto req = librbd::io::ImageDispatchSpec<I>::create_flush_request(
     image_ctx, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {});
@@ -402,6 +402,7 @@ void ImageRequestWQ<I>::aio_flush(AioCompletion *c, bool native_async) {
     queue(ImageDispatchSpec<I>::create_flush_request(
             m_image_ctx, c, FLUSH_SOURCE_USER, trace));
   } else {
+    c->start_op();
     ImageRequest<I>::aio_flush(&m_image_ctx, c, FLUSH_SOURCE_USER, trace);
     finish_in_flight_io();
   }
index c5fa86f57bcb50e04b4294c9632528b350804a5c..19de24c1d8e8f17b96563063f5706f1b7bf12c70 100644 (file)
@@ -193,7 +193,7 @@ void ResizeRequest<I>::send_flush_cache() {
   RWLock::RLocker owner_locker(image_ctx.owner_lock);
   auto ctx = create_context_callback<
     ResizeRequest<I>, &ResizeRequest<I>::handle_flush_cache>(this);
-  auto aio_comp = io::AioCompletion::create(
+  auto aio_comp = io::AioCompletion::create_and_start(
     ctx, util::get_image_ctx(&image_ctx), io::AIO_TYPE_FLUSH);
   auto req = io::ImageDispatchSpec<I>::create_flush_request(
     image_ctx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
index b7137b5c612b20537bfab02c2731fe486836b14c..88b01c60fe0af6920706fa21499fe2d814d0e7e8 100644 (file)
@@ -857,7 +857,7 @@ TEST_F(TestJournalReplay, ObjectPosition) {
 
   // user flush requests are ignored when journaling + cache are enabled
   C_SaferCond flush_ctx;
-  aio_comp = librbd::io::AioCompletion::create(
+  aio_comp = librbd::io::AioCompletion::create_and_start(
     &flush_ctx, ictx, librbd::io::AIO_TYPE_FLUSH);
   auto req = librbd::io::ImageDispatchSpec<>::create_flush_request(
     *ictx, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {});
index fbd3381116d280531640c2bed0e513e2cc3273c6..7f9ae105daece8eb08c934a5b1e8b39096a83890 100644 (file)
@@ -30,7 +30,7 @@ namespace {
 
 int flush(librbd::ImageCtx *image_ctx) {
   C_SaferCond ctx;
-  auto aio_comp = librbd::io::AioCompletion::create(
+  auto aio_comp = librbd::io::AioCompletion::create_and_start(
     &ctx, image_ctx, librbd::io::AIO_TYPE_FLUSH);
   auto req = librbd::io::ImageDispatchSpec<>::create_flush_request(
     *image_ctx, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {});