]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: complete flush context w/o holding locks
authorJason Dillaman <dillaman@redhat.com>
Tue, 14 Jul 2015 12:43:35 +0000 (08:43 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 6 Nov 2015 01:42:42 +0000 (20:42 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/journal/JournalRecorder.cc
src/journal/JournalRecorder.h

index 938cf70729342ba7435f33746fdba6432f9f4614..a921af26c7ef1437b162259e4435e651c1ea5356 100644 (file)
@@ -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) {
index 186fe05c78ad1c76db4e0b1494762b0c22287507..4c3489fcb889261f5a5ffef10ca0e7ab871439d2 100644 (file)
@@ -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;