From 6e58ed9031fac31abb040cbb46a84a632ad80c90 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 16 Sep 2016 17:45:51 -0400 Subject: [PATCH] os/bluestore/BlueFS: log dirty files at sync time Instead of logging an updated fnode every time we dirty the metadata, log it only once, right before we flush. This greatly reduces the amount of metadata we have to write. Signed-off-by: Sage Weil --- src/os/bluestore/BlueFS.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 92987eec9876..46eaae253e36 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1279,14 +1279,26 @@ int BlueFS::_flush_and_sync_log(std::unique_lock& l, << log_seq_stable << ", done" << dendl; return 0; } - if (log_t.empty()) { + if (log_t.empty() && dirty_files.empty()) { dout(10) << __func__ << " want_seq " << want_seq - << " " << log_t << " not dirty, no-op" << dendl; + << " " << log_t << " not dirty, dirty_files empty, 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; + + // log dirty files + auto lsi = dirty_files.find(seq); + if (lsi != dirty_files.end()) { + dout(20) << __func__ << " " << lsi->second.size() << " dirty_files" << dendl; + for (auto &f : lsi->second) { + dout(20) << __func__ << " op_file_update " << f.fnode << dendl; + log_t.op_file_update(f.fnode); + } + } + dout(10) << __func__ << " " << log_t << dendl; assert(!log_t.empty()); @@ -1432,7 +1444,6 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length) if (must_dirty) { h->file->fnode.mtime = ceph_clock_now(NULL); assert(h->file->fnode.ino >= 1); - log_t.op_file_update(h->file->fnode); if (h->file->dirty_seq == 0) { h->file->dirty_seq = log_seq + 1; dirty_files[h->file->dirty_seq].push_back(*h->file); -- 2.47.3