From: Sage Weil Date: Fri, 21 Jan 2011 18:43:53 +0000 (-0800) Subject: filestore: don't wait min sync interval on explicit sync() X-Git-Tag: v0.24.2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=943fd14f7923f49d37435d255ee5fd133e4f106a;p=ceph.git filestore: don't wait min sync interval on explicit sync() Also, if we do wait longer, wait on the same cond. Signed-off-by: Sage Weil --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 179d1757dae..dbe782d95de 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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 fin; @@ -2406,6 +2412,7 @@ void FileStore::_start_sync() void FileStore::start_sync() { Mutex::Locker l(lock); + force_sync = true; sync_cond.Signal(); } diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 536c7466aff..df1ea71b887 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -75,6 +75,7 @@ class FileStore : public JournalingObjectStore { // sync thread Mutex lock; + bool force_sync; Cond sync_cond; uint64_t sync_epoch; list 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) {