From a51d9d8525a721fdc8d2e576cc816461b78af9a1 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 14 Jul 2015 08:43:35 -0400 Subject: journal: complete flush context w/o holding locks Signed-off-by: Jason Dillaman --- src/journal/JournalRecorder.cc | 17 +++++++++++------ src/journal/JournalRecorder.h | 6 +++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/journal/JournalRecorder.cc b/src/journal/JournalRecorder.cc index 938cf707293..a921af26c7e 100644 --- a/src/journal/JournalRecorder.cc +++ b/src/journal/JournalRecorder.cc @@ -72,13 +72,18 @@ Future JournalRecorder::append(const std::string &tag, } void JournalRecorder::flush(Context *on_safe) { - Mutex::Locker locker(m_lock); - - C_Flush *ctx = new C_Flush(on_safe, m_object_ptrs.size()); - for (ObjectRecorderPtrs::iterator it = m_object_ptrs.begin(); - it != m_object_ptrs.end(); ++it) { - it->second->flush(ctx); + C_Flush *ctx; + { + Mutex::Locker locker(m_lock); + + ctx = new C_Flush(on_safe, m_object_ptrs.size()); + for (ObjectRecorderPtrs::iterator it = m_object_ptrs.begin(); + it != m_object_ptrs.end(); ++it) { + it->second->flush(ctx); + } } + + ctx->unblock(); } ObjectRecorderPtr JournalRecorder::get_object(uint8_t splay_offset) { diff --git a/src/journal/JournalRecorder.h b/src/journal/JournalRecorder.h index 186fe05c78a..4c3489fcb88 100644 --- a/src/journal/JournalRecorder.h +++ b/src/journal/JournalRecorder.h @@ -64,9 +64,13 @@ private: int ret_val; C_Flush(Context *_on_finish, size_t _pending_flushes) - : on_finish(_on_finish), pending_flushes(_pending_flushes), ret_val(0) { + : on_finish(_on_finish), pending_flushes(_pending_flushes + 1), + ret_val(0) { } + void unblock() { + complete(0); + } virtual void complete(int r) { if (r < 0 && ret_val == 0) { ret_val = r; -- cgit v1.2.3