summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Dillaman <dillaman@redhat.com>2015-07-14 14:43:35 +0200
committerJason Dillaman <dillaman@redhat.com>2015-11-06 02:42:42 +0100
commita51d9d8525a721fdc8d2e576cc816461b78af9a1 (patch)
tree104113a49b0921019b1b4a814c41ca84c53023e7
parentjournal: Journaler::stop_append should be async (diff)
downloadceph-a51d9d8525a721fdc8d2e576cc816461b78af9a1.tar.xz
ceph-a51d9d8525a721fdc8d2e576cc816461b78af9a1.zip
journal: complete flush context w/o holding locks
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
-rw-r--r--src/journal/JournalRecorder.cc17
-rw-r--r--src/journal/JournalRecorder.h6
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;