From: Sage Weil Date: Fri, 24 Jun 2016 13:43:52 +0000 (-0400) Subject: os/bluestore/BlueFS: make _sync_and_flush_log smarter X-Git-Tag: ses5-milestone5~545^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97699334acd59e9530d36b13d3a8408cabf848ef;p=ceph.git os/bluestore/BlueFS: make _sync_and_flush_log smarter If we know what event we need to wait for, only wait long enough for it to flush. This helps the situation where another thread flushed what we needed, and more dirty stuff was added to log_t, but we don't need to wait for that too for our caller to be happy. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 55c7df226c35..61f9388d8e8e 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1023,17 +1023,26 @@ void BlueFS::_pad_bl(bufferlist& bl) } } -int BlueFS::_flush_and_sync_log(std::unique_lock& l) +int BlueFS::_flush_and_sync_log(std::unique_lock& l, + uint64_t want_seq) { while (log_flushing) { - dout(10) << __func__ << " log is currently flushing, waiting" << dendl; + dout(10) << __func__ << " want_seq " << want_seq + << " log is currently flushing, waiting" << dendl; log_cond.wait(l); } + if (want_seq && want_seq <= log_seq_stable) { + dout(10) << __func__ << " want_seq " << want_seq << " <= log_seq_stable " + << log_seq_stable << ", done" << dendl; + return 0; + } if (log_t.empty()) { - dout(10) << __func__ << " " << log_t << " not dirty, no-op" << dendl; + dout(10) << __func__ << " want_seq " << want_seq + << " " << log_t << " not dirty, no-op" << dendl; return 0; } uint64_t seq = log_t.seq = ++log_seq; + assert(want_seq == 0 || want_seq <= seq); log_t.uuid = super.uuid; dout(10) << __func__ << " " << log_t << dendl; assert(!log_t.empty()); @@ -1325,7 +1334,7 @@ void BlueFS::_fsync(FileWriter *h, std::unique_lock& l) uint64_t s = log_seq; dout(20) << __func__ << " file metadata was dirty (" << old_dirty_seq << ") on " << h->file->fnode << ", flushing log" << dendl; - _flush_and_sync_log(l); + _flush_and_sync_log(l, old_dirty_seq); assert(h->file->dirty_seq == 0 || // cleaned h->file->dirty_seq > s); // or redirtied by someone else } diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 5feb68329ddd..ac07e1c3868e 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -238,7 +238,8 @@ private: void wait_for_aio(FileWriter *h); // safe to call without a lock void _fsync(FileWriter *h, std::unique_lock& l); - int _flush_and_sync_log(std::unique_lock& l); + int _flush_and_sync_log(std::unique_lock& l, + uint64_t want_seq = 0); uint64_t _estimate_log_size(); void _maybe_compact_log(); void _compact_log();