From a1ea1edce9332fa1730625629e3b4e16f02caaf4 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 13 Jun 2016 20:20:33 -0400 Subject: [PATCH] librbd: track in-flight flush events for journaling The tracking for flush events was accidentally dropped. This can result in the journal being closed too early since it might miss in-flight flush ops. Signed-off-by: Jason Dillaman --- src/librbd/AioCompletion.cc | 4 ++-- src/librbd/AioCompletion.h | 2 +- src/librbd/AioImageRequest.cc | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librbd/AioCompletion.cc b/src/librbd/AioCompletion.cc index db4b2ca74febe..1e892acb79473 100644 --- a/src/librbd/AioCompletion.cc +++ b/src/librbd/AioCompletion.cc @@ -135,11 +135,11 @@ namespace librbd { } } - void AioCompletion::start_op() { + void AioCompletion::start_op(bool ignore_type) { Mutex::Locker locker(lock); assert(ictx != nullptr); assert(!async_op.started()); - if (state == STATE_PENDING && aio_type != AIO_TYPE_FLUSH) { + if (state == STATE_PENDING && (ignore_type || aio_type != AIO_TYPE_FLUSH)) { async_op.start_op(*ictx); } } diff --git a/src/librbd/AioCompletion.h b/src/librbd/AioCompletion.h index 37d8977be95e2..758b1d8a66938 100644 --- a/src/librbd/AioCompletion.h +++ b/src/librbd/AioCompletion.h @@ -118,7 +118,7 @@ namespace librbd { void finalize(ssize_t rval); void init_time(ImageCtx *i, aio_type_t t); - void start_op(); + void start_op(bool ignore_type = false); void fail(int r); void complete(); diff --git a/src/librbd/AioImageRequest.cc b/src/librbd/AioImageRequest.cc index 3b2868801da18..1877af146965a 100644 --- a/src/librbd/AioImageRequest.cc +++ b/src/librbd/AioImageRequest.cc @@ -472,6 +472,8 @@ void AioImageFlush::send_request() { C_AioRequest *req_comp = new C_AioRequest(m_aio_comp); m_image_ctx.flush(req_comp); + // track flush op for block writes + m_aio_comp->start_op(true); m_aio_comp->put(); m_image_ctx.perfcounter->inc(l_librbd_aio_flush);