From f2def83b7a4a98bc60db5ba8936d78a49abace88 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Thu, 12 May 2016 18:22:12 +0800 Subject: [PATCH] rbd: Skip rbd cache flush if journaling is enabled under aio_flush With journaling rbd writes will be persisteted on rbd journal objects. The journal will be replayed if crash happen. So it's not necessary to flush rbd_cache in this case. This will improve the flush latency. This patch adds checking on handling aio_flush: if journaling is enabled, rbd cache flushing is skipped. In a system flush(ImageCtx::flush) the cache is flushed even w/ journaling where we truly do need to flush all IO out to disk. Fixes: http://tracker.ceph.com/issues/15761 Signed-off-by: Yuan Zhou --- src/librbd/AioImageRequest.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/librbd/AioImageRequest.cc b/src/librbd/AioImageRequest.cc index 1877af146965a..413e0e62f9301 100644 --- a/src/librbd/AioImageRequest.cc +++ b/src/librbd/AioImageRequest.cc @@ -454,24 +454,28 @@ void AioImageFlush::send_request() { !m_image_ctx.journal->is_journal_replaying()); } - m_aio_comp->set_request_count(journaling ? 2 : 1); - if (journaling) { // in-flight ops are flushed prior to closing the journal uint64_t journal_tid = m_image_ctx.journal->append_io_event( journal::EventEntry(journal::AioFlushEvent()), AioObjectRequests(), 0, 0, false); + m_aio_comp->set_request_count(2); + C_FlushJournalCommit *ctx = new C_FlushJournalCommit(m_image_ctx, m_aio_comp, journal_tid); + C_AioRequest *req_comp = new C_AioRequest(m_aio_comp); m_image_ctx.journal->flush_event(journal_tid, ctx); m_aio_comp->associate_journal_event(journal_tid); + m_image_ctx.flush_async_operations(req_comp); + } else { + // flush rbd cache only when journaling is not enabled + m_aio_comp->set_request_count(1); + C_AioRequest *req_comp = new C_AioRequest(m_aio_comp); + m_image_ctx.flush(req_comp); } - 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(); -- 2.39.5