]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: flush() will wait for queued transactions to be readable
authorSage Weil <sage@newdream.net>
Fri, 29 Jan 2010 19:22:35 +0000 (11:22 -0800)
committerSage Weil <sage@newdream.net>
Fri, 29 Jan 2010 19:22:35 +0000 (11:22 -0800)
src/os/FileJournal.cc
src/os/FileStore.cc
src/os/FileStore.h
src/os/ObjectStore.h

index 030eb56ecdc4ad1c5ab42cc797b77e60f08d937a..4df8285db4c62d12090b9bcaaf128f15505e8d56 100644 (file)
@@ -553,6 +553,8 @@ void FileJournal::flush()
     write_empty_cond.Wait(write_lock);
   }
   write_lock.Unlock();
+  dout(10) << "flush waiting for finisher" << dendl;
+  finisher->wait_for_empty();
   dout(10) << "flush done" << dendl;
 }
 
index eeac8db53bc556d707c2b98405a45d191ffe5eb7..340bf0abd8d7e2f487eb2f486b81891d0034ae56 100644 (file)
@@ -1386,34 +1386,52 @@ void FileStore::sync(Context *onsafe)
   sync();
 }
 
-void FileStore::sync_and_flush()
+void FileStore::_flush_op_queue()
 {
-  dout(10) << "sync_and_flush" << dendl;
-  sync();
-  
-  if (journal)
-    journal->flush();
-
-  if (g_conf.filestore_journal_writeahead) {
-    dout(10) << "sync_and_flush waiting for journal finisher" << dendl;
-    finisher.wait_for_empty();
-  }
-  
   op_lock.Lock();
   while (!op_queue.empty()) {
-    dout(10) << "sync_and_flush waiting for op queue to flush" << dendl;
+    dout(10) << "_flush_op_queue waiting for op queue to flush" << dendl;
     op_empty_cond.Wait(op_lock);
   }
   op_lock.Unlock();
 
-  dout(10) << "sync_and_flush waiting for apply finisher" << dendl;
+  dout(10) << "_flush_op_queue waiting for apply finisher" << dendl;
   op_finisher.wait_for_empty();
+}
 
-  if (!g_conf.filestore_journal_writeahead) {
-    dout(10) << "sync_and_flush waiting for journal finisher" << dendl;
-    finisher.wait_for_empty();
+/*
+ * flush - make every queued write readable
+ */
+void FileStore::flush()
+{
+  dout(10) << "flush" << dendl;
+  if (g_conf.filestore_journal_writeahead) {
+    if (journal)
+      journal->flush();
   }
 
+  _flush_op_queue();
+}
+
+/*
+ * sync_and_flush - make every queued write readable AND committed to disk
+ */
+void FileStore::sync_and_flush()
+{
+  dout(10) << "sync_and_flush" << dendl;
+
+  if (g_conf.filestore_journal_writeahead) {
+    if (journal)
+      journal->flush();
+    _flush_op_queue();
+  } else if (g_conf.filestore_journal_parallel) {
+    _flush_op_queue();
+    sync();
+  } else {
+    _flush_op_queue();
+    sync();
+  }
   dout(10) << "sync_and_flush done" << dendl;
 }
 
index b86677475c1ebffd814bfc14ac93ca241f06d09e..fcb8d2bbb7166b067d40c6ee63e38b0a3ea9e766 100644 (file)
@@ -173,6 +173,8 @@ class FileStore : public JournalingObjectStore {
 
   void sync();
   void sync(Context *onsafe);
+  void _flush_op_queue();
+  void flush();
   void sync_and_flush();
 
   // attrs
index b29f3c52add3a293479da9d45e8fa0eab1bb0f32..fe9c320b1649f8b04be977eb078f39e99f1e59da 100644 (file)
@@ -519,6 +519,7 @@ public:
 
   virtual void sync(Context *onsync) {}
   virtual void sync() {}
+  virtual void flush() {}
   virtual void sync_and_flush() {}
     
   virtual void _fake_writes(bool b) {};