]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: fix journal flush
authorSage Weil <sage@newdream.net>
Wed, 27 Jan 2010 19:24:30 +0000 (11:24 -0800)
committerSage Weil <sage@newdream.net>
Wed, 27 Jan 2010 19:24:30 +0000 (11:24 -0800)
src/os/FileJournal.cc
src/os/FileJournal.h
src/os/FileStore.cc
src/os/Journal.h

index 3d03b6811a16e97593df9aa43f9687cc9c894a17..f7b0b17a0e8adde4904d9317a97060e2f5d65a2b 100644 (file)
@@ -545,6 +545,17 @@ void FileJournal::do_write(bufferlist& bl)
   }
 }
 
+void FileJournal::flush()
+{
+  write_lock.Lock();
+  while ((!writeq.empty() || writing) && !write_stop) {
+    dout(10) << "flush waiting for writeq to empty and writes to complete" << dendl;
+    write_empty_cond.Wait(write_lock);
+  }
+  write_lock.Unlock();
+  dout(10) << "flush done" << dendl;
+}
+
 
 void FileJournal::write_thread_entry()
 {
@@ -556,6 +567,7 @@ void FileJournal::write_thread_entry()
     if (writeq.empty()) {
       // sleep
       dout(20) << "write_thread_entry going to sleep" << dendl;
+      write_empty_cond.Signal();
       write_cond.Wait(write_lock);
       dout(20) << "write_thread_entry woke up" << dendl;
       continue;
@@ -568,7 +580,7 @@ void FileJournal::write_thread_entry()
       prepare_multi_write(bl);
     do_write(bl);
   }
-
+  write_empty_cond.Signal();
   write_lock.Unlock();
   dout(10) << "write_thread_entry finish" << dendl;
 }
index d217c50ef9d82d104e905cbc9c2ea9c09ebb5c7f..93c97a00e8fee29e6370e0094304d239c85f7fdb 100644 (file)
@@ -100,7 +100,7 @@ private:
   
   // write thread
   Mutex write_lock;
-  Cond write_cond;
+  Cond write_cond, write_empty_cond;
   bool write_stop;
 
   Cond commit_cond;
@@ -157,6 +157,8 @@ private:
   int open(__u64 last_seq);
   void close();
 
+  void flush();
+
   bool is_writeable() {
     return read_pos == 0;
   }
index 0c8b1ab8e3b10e2a7defb3ee870d26b3e80af247..c64aaf4c0e67b0d5f2124118026dfc3b2f53978d 100644 (file)
@@ -1391,6 +1391,9 @@ void FileStore::sync_and_flush()
   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();
index 26455908cd545971c694280edfbc480362fcaa0a..0584e66a2ba516fefc39b08bb0ddce26157f3666 100644 (file)
@@ -37,6 +37,8 @@ public:
   virtual int open(__u64 last_seq) = 0;
   virtual void close() = 0;
 
+  virtual void flush() = 0;
+
   void set_wait_on_full(bool b) { wait_on_full = b; }
 
   // writes