void FileStore::sync_entry()
{
- Cond othercond;
-
lock.Lock();
while (!stop) {
utime_t max_interval;
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;
void FileStore::start_sync()
{
Mutex::Locker l(lock);
+ force_sync = true;
sync_cond.Signal();
}
// sync thread
Mutex lock;
+ bool force_sync;
Cond sync_cond;
uint64_t sync_epoch;
list<Context*> sync_waiters;
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) {