From: John Spray Date: Mon, 13 Feb 2017 00:16:29 +0000 (+0000) Subject: osdc: less aggressive prefetch in read/write Journaler X-Git-Tag: v12.0.1~140^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8d4f6b92cba0d2b15769a5ececdeab2692e2a3e3;p=ceph.git 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 --- diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index 45cfecb86256..b19c3cbeaabc 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); } }