From f967b17c488329f5f464ff76932c02c1d0e01511 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 2 Sep 2016 15:31:20 -0400 Subject: [PATCH] os/bluestore/BlueFS: factor unflushed log into runway calculation Include the size of the in-memory buffer we haven't yet flushed into the runway calculation when deciding whether to allocate more log space. Reported-by: Somnath Roy Signed-off-by: Sage Weil --- src/os/bluestore/BlueFS.cc | 5 +++-- src/os/bluestore/BlueFS.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 9c7e21eb72b..b60b0966ae1 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1284,8 +1284,9 @@ int BlueFS::_flush_and_sync_log(std::unique_lock& l, assert(!log_t.empty()); // allocate some more space (before we run out)? - uint64_t runway = log_writer->file->fnode.get_allocated() - log_writer->pos; - if (runway < g_conf->bluefs_min_log_runway) { + int64_t runway = log_writer->file->fnode.get_allocated() - + log_writer->get_effective_write_pos(); + if (runway < (int64_t)g_conf->bluefs_min_log_runway) { dout(10) << __func__ << " allocating more log runway (0x" << std::hex << runway << std::dec << " remaining)" << dendl; while (new_log_writer) { diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 43681a35347..4ffee086bc6 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -135,6 +135,10 @@ public: void append(bufferptr& bp) { buffer.append(bp); } + + uint64_t get_effective_write_pos() { + return pos + buffer.length(); + } }; struct FileReaderBuffer { -- 2.39.5