From bfc9690dd158166956f877b799d317866f2d51c5 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 18 Dec 2015 15:14:34 -0500 Subject: [PATCH] librbd: skip journal event if write/discard was no-op Signed-off-by: Jason Dillaman --- src/librbd/AioImageRequest.cc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/librbd/AioImageRequest.cc b/src/librbd/AioImageRequest.cc index f0c3228119c6b..c1d7602ec36ae 100644 --- a/src/librbd/AioImageRequest.cc +++ b/src/librbd/AioImageRequest.cc @@ -248,23 +248,28 @@ void AbstractAioImageWrite::send_request() { !m_image_ctx.journal->is_journal_replaying()); } + if (!object_extents.empty()) { + m_aio_comp->set_request_count( + cct, object_extents.size() + get_cache_request_count(journaling)); + + AioObjectRequests requests; + send_object_requests(object_extents, snapc, + (journaling ? &requests : nullptr)); + + if (journaling) { + // in-flight ops are flushed prior to closing the journal + assert(m_image_ctx.journal != NULL); + journal_tid = append_journal_event(requests, m_synchronous); + } - m_aio_comp->set_request_count( - m_image_ctx.cct, object_extents.size() + - get_cache_request_count(journaling)); - - AioObjectRequests requests; - send_object_requests(object_extents, snapc, (journaling ? &requests : NULL)); - - if (journaling) { - // in-flight ops are flushed prior to closing the journal - assert(m_image_ctx.journal != NULL); - journal_tid = append_journal_event(requests, m_synchronous); + if (m_image_ctx.object_cacher != NULL) { + send_cache_requests(object_extents, journal_tid); + } + } else { + // no IO to perform -- fire completion + m_aio_comp->unblock(cct); } - if (m_image_ctx.object_cacher != NULL) { - send_cache_requests(object_extents, journal_tid); - } update_stats(clip_len); m_aio_comp->put(); } -- 2.39.5