]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: make trigger_commit() wake up sync; adjust locking
authorSage Weil <sage@newdream.net>
Thu, 10 Nov 2011 19:31:22 +0000 (11:31 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 11 Nov 2011 05:12:38 +0000 (21:12 -0800)
We need to wake up the sync thread (duh).

Also, we need to obey the FileJournal::lock -> journal_lock locking
order.

Also, lockdep is broken. :(

Signed-off-by: Sage Weil <sage@newdream.net>
src/os/FileStore.cc
src/os/FileStore.h
src/os/JournalingObjectStore.cc
src/os/JournalingObjectStore.h

index 131484888a21f03cd2bfd5d13f62a7e99cb5dd07..2787110e58d52eee6e2c4b31d038dd53ec316809 100644 (file)
@@ -3161,6 +3161,23 @@ void FileStore::start_sync(Context *onsafe)
   dout(10) << "start_sync" << dendl;
 }
 
+void FileStore::trigger_commit(uint64_t seq)
+{
+  /*
+   * crib the lock -> journal_lock.  we need to start the sync under lock,
+   * but once we release lock it will block because journal_lock is held.
+   * _trigger_commit() expects journal_lock to be held by the caller.
+   */
+  lock.Lock();
+  dout(10) << "trigger_commit seq" << dendl;
+  force_sync = true;
+  sync_cond.Signal();
+  journal_lock.Lock();
+  lock.Unlock();
+  _trigger_commit(seq);
+  journal_lock.Unlock();
+}
+
 void FileStore::sync()
 {
   Mutex l("FileStore::sync");
index 033dad31faeaeba4ec135c9c588355f0f9839fc3..09eea071927f9a69c5cf23580428f064b6590445 100644 (file)
@@ -103,6 +103,8 @@ class FileStore : public JournalingObjectStore,
     }
   } sync_thread;
 
+  void trigger_commit(uint64_t);
+
   void sync_fs(); // actuall sync underlying fs
 
   // -- op workqueue --
index 80ee981eaea8175458702a8f15b9e850d98b1196..66257bf5d9a215be13b44957273bd224104caa1d 100644 (file)
@@ -180,18 +180,19 @@ void JournalingObjectStore::op_submit_finish(uint64_t op)
  * an open_ops reference.  it should block only long enough for the
  * commit to _start_ waiting for open_ops, but not longer or else we
  * will deadlock.
+ *
+ * caller must hold journal_lock.
  */
-void JournalingObjectStore::trigger_commit(uint64_t seq)
+void JournalingObjectStore::_trigger_commit(uint64_t seq)
 {
+  assert(journal_lock.is_locked());
   dout(10) << "trigger_commit " << seq << dendl;
-  journal_lock.Lock();
   force_commit = true;
   while (!blocked && committing_seq < seq) {
     dout(20) << "trigger_commit not blocked and seq " << seq << " > committing " << committing_seq << dendl;
     cond.Wait(journal_lock);
   }
   dout(10) << "trigger_commit triggered, will commit something >= " << seq << dendl;
-  journal_lock.Unlock();
 }
 
 bool JournalingObjectStore::commit_start() 
index 3b4f7cf68ce1472f0b34e9b90d2cb2eb03a41ab7..a701a7d12e3a6c11e099b0c8e99a602e44c2d6f2 100644 (file)
@@ -45,7 +45,8 @@ protected:
   void journal_stop();
   int journal_replay(uint64_t fs_op_seq);
 
-  void trigger_commit(uint64_t op_seq);
+  virtual void trigger_commit(uint64_t op_seq) = 0;
+  void _trigger_commit(uint64_t op_seq);
 
   // --
   uint64_t op_submit_start();