]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc: less aggressive prefetch in read/write Journaler
authorJohn Spray <john.spray@redhat.com>
Mon, 13 Feb 2017 00:16:29 +0000 (00:16 +0000)
committerJohn Spray <john.spray@redhat.com>
Wed, 8 Mar 2017 10:27:00 +0000 (10:27 +0000)
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 <john.spray@redhat.com>
src/osdc/Journaler.cc

index 45cfecb86256cc46f631d65aced4a93aa70b3b8d..b19c3cbeaabc73ca71a0653f6070a7653f629248 100644 (file)
@@ -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);
   }
 }