From 8d4f6b92cba0d2b15769a5ececdeab2692e2a3e3 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 13 Feb 2017 00:16:29 +0000 Subject: [PATCH] osdc: less aggressive prefetch in read/write Journaler Previously, if doing a write/is_readable/write/is_readable sequence, you'd end up doing a flush after every write, even though there was already a flush in flight that would advance the readable-ness of the journal. Because this flush-during-read path is only active when using a read/write journal such as in PurgeQueue, tweak the behaviour to suit this case. Signed-off-by: John Spray --- src/osdc/Journaler.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index 45cfecb86256c..b19c3cbeaabc7 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -946,9 +946,6 @@ void Journaler::_assimilate_prefetch() void Journaler::_issue_read(uint64_t len) { - // make sure we're fully flushed - _do_flush(); - // stuck at safe_pos? (this is needed if we are reading the tail of // a journal we are also writing to) assert(requested_pos <= safe_pos); @@ -1024,6 +1021,19 @@ void Journaler::_prefetch() ldout(cct, 10) << "_prefetch " << pf << " requested_pos " << requested_pos << " < target " << target << " (" << raw_target << "), prefetching " << len << dendl; + + if (flush_pos == safe_pos && write_pos > safe_pos) { + // If we are reading and writing the journal, then we may need + // to issue a flush if one isn't already in progress. + // Avoid doing a flush every time so that if we do write/read/write/read + // we don't end up flushing after every write. + ldout(cct, 10) << "_prefetch: requested_pos=" << requested_pos + << ", read_pos=" << read_pos + << ", write_pos=" << write_pos + << ", safe_pos=" << safe_pos << dendl; + _do_flush(); + } + _issue_read(len); } } -- 2.39.5