]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: don't wait min sync interval on explicit sync()
authorSage Weil <sage@newdream.net>
Fri, 21 Jan 2011 18:43:53 +0000 (10:43 -0800)
committerSage Weil <sage@newdream.net>
Mon, 24 Jan 2011 18:59:42 +0000 (10:59 -0800)
Also, if we do wait longer, wait on the same cond.

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

index 179d1757dae37c498a3a0114c6e5f4738072783c..dbe782d95de5405b454e646bc09053c0d726dbe2 100644 (file)
@@ -2247,8 +2247,6 @@ void FileStore::flusher_entry()
 
 void FileStore::sync_entry()
 {
-  Cond othercond;
-
   lock.Lock();
   while (!stop) {
     utime_t max_interval;
@@ -2256,21 +2254,29 @@ void FileStore::sync_entry()
     utime_t min_interval;
     min_interval.set_from_double(g_conf.filestore_min_sync_interval);
 
-    dout(20) << "sync_entry waiting for max_interval " << max_interval << dendl;
     utime_t startwait = g_clock.now();
+    if (!force_sync) {
+      dout(20) << "sync_entry waiting for max_interval " << max_interval << dendl;
+      sync_cond.WaitInterval(lock, max_interval);
+    } else {
+      dout(20) << "sync_entry not waiting, force_sync set" << dendl;
+    }
 
-    sync_cond.WaitInterval(lock, max_interval);
-
-    // wait for at least the min interval
-    utime_t woke = g_clock.now();
-    woke -= startwait;
-    dout(20) << "sync_entry woke after " << woke << dendl;
-    if (woke < min_interval) {
-      utime_t t = min_interval;
-      t -= woke;
-      dout(20) << "sync_entry waiting for another " << t 
-              << " to reach min interval " << min_interval << dendl;
-      othercond.WaitInterval(lock, t);
+    if (force_sync) {
+      dout(20) << "sync_entry force_sync set" << dendl;
+      force_sync = false;
+    } else {
+      // wait for at least the min interval
+      utime_t woke = g_clock.now();
+      woke -= startwait;
+      dout(20) << "sync_entry woke after " << woke << dendl;
+      if (woke < min_interval) {
+       utime_t t = min_interval;
+       t -= woke;
+       dout(20) << "sync_entry waiting for another " << t 
+                << " to reach min interval " << min_interval << dendl;
+       sync_cond.WaitInterval(lock, t);
+      }
     }
 
     list<Context*> fin;
@@ -2406,6 +2412,7 @@ void FileStore::_start_sync()
 void FileStore::start_sync()
 {
   Mutex::Locker l(lock);
+  force_sync = true;
   sync_cond.Signal();
 }
 
index 536c7466affe18136f6f79156051c9c174c7f42a..df1ea71b8873a54bd2d62955edcac869df19181d 100644 (file)
@@ -75,6 +75,7 @@ class FileStore : public JournalingObjectStore {
 
   // sync thread
   Mutex lock;
+  bool force_sync;
   Cond sync_cond;
   uint64_t sync_epoch;
   list<Context*> sync_waiters;
@@ -235,7 +236,7 @@ class FileStore : public JournalingObjectStore {
     attrs(this), fake_attrs(false), 
     collections(this), fake_collections(false),
     lock("FileStore::lock"),
-    sync_epoch(0), stop(false), sync_thread(this),
+    force_sync(false), sync_epoch(0), stop(false), sync_thread(this),
     op_queue_len(0), op_queue_bytes(0), next_finish(0),
     op_tp("FileStore::op_tp", g_conf.filestore_op_threads), op_wq(this, &op_tp),
     flusher_queue_len(0), flusher_thread(this) {