From: Sage Weil Date: Wed, 22 Jun 2016 19:20:55 +0000 (-0400) Subject: os/bluestore/BlueFS: _should_compact_log X-Git-Tag: ses5-milestone5~93^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb7c836274e6506f996e1710ec6665d94f9b540d;p=ceph.git os/bluestore/BlueFS: _should_compact_log Signed-off-by: Varada Kari --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 8fe5e80463d..31548d971d3 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -918,7 +918,8 @@ uint64_t BlueFS::_estimate_log_size() return ROUND_UP_TO(size, super.block_size); } -void BlueFS::_maybe_compact_log() + +bool BlueFS::_should_compact_log() { uint64_t current = log_writer->file->fnode.size; uint64_t expected = _estimate_log_size(); @@ -928,13 +929,11 @@ void BlueFS::_maybe_compact_log() << " ratio " << ratio << dendl; if (current < g_conf->bluefs_log_compact_min_size || ratio < g_conf->bluefs_log_compact_min_ratio) - return; - _compact_log(); - dout(20) << __func__ << " done, actual " << log_writer->file->fnode.size - << " vs expected " << expected << dendl; + return false; + return true; } -void BlueFS::_compact_log() +void BlueFS::_compact_log_sync() { // FIXME: we currently hold the lock while writing out the compacted log, // which may mean a latency spike. we could drop the lock while writing out @@ -1448,7 +1447,9 @@ void BlueFS::sync_metadata() p->commit_finish(); } } - _maybe_compact_log(); + if (_should_compact_log()) { + _compact_log_sync(); + } utime_t end = ceph_clock_now(NULL); utime_t dur = end - start; dout(10) << __func__ << " done in " << dur << dendl; diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index e7c29cbf2df..fbd1e10408e 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -241,8 +241,8 @@ private: 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(); + bool _should_compact_log(); + void _compact_log_sync(); //void _aio_finish(void *priv);