From 92bf85efd4cfe66bf86d9b5ef602f49e341b0251 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 13 Feb 2017 12:00:42 +0000 Subject: [PATCH] osdc: expose Journaler::write_head_needed So that callers on the read side can optionally do their own write_head calls according to the same condition that Journaler uses internally for its write_head during _flush() condition. Signed-off-by: John Spray --- src/osdc/Journaler.cc | 9 +++++++-- src/osdc/Journaler.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index b19c3cbeaab..116432c3b79 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -722,12 +722,17 @@ void Journaler::_flush(C_OnFinisher *onsafe) } // write head? - if (last_wrote_head + seconds(cct->_conf->journaler_write_head_interval) - < ceph::real_clock::now()) { + if (_write_head_needed()) { _write_head(); } } +bool Journaler::_write_head_needed() +{ + return last_wrote_head + seconds(cct->_conf->journaler_write_head_interval) + < ceph::real_clock::now(); +} + /*************** prezeroing ******************/ diff --git a/src/osdc/Journaler.h b/src/osdc/Journaler.h index 6a731993bc0..26a09a7aeda 100644 --- a/src/osdc/Journaler.h +++ b/src/osdc/Journaler.h @@ -467,6 +467,13 @@ public: trimming_pos = trimmed_pos = p; } + bool _write_head_needed(); + bool write_head_needed() { + lock_guard l(lock); + return _write_head_needed(); + } + + void trim(); void trim_tail() { lock_guard l(lock); -- 2.39.5