From: Adam Kupczyk Date: Mon, 8 Jun 2020 10:40:19 +0000 (+0200) Subject: os/bluestore: Added check that protects against corrupting BlueFS replay log X-Git-Tag: v14.2.17~63^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=22b84f0a7837bd2901ff30aadd74048afc35006a;p=ceph.git os/bluestore: Added check that protects against corrupting BlueFS replay log This fixes https://tracker.ceph.com/issues/46194 Signed-off-by: Adam Kupczyk (cherry picked from commit d10a9602fe0ac6dfa5fde9c12dbcf713c65f6c7e) --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 6e45821965d..3575953a56a 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -2204,6 +2204,7 @@ int BlueFS::_flush_and_sync_log(std::unique_lock& l, // allocate some more space (before we run out)? int64_t runway = log_writer->file->fnode.get_allocated() - log_writer->get_effective_write_pos(); + bool just_expanded_log = false; if (runway < (int64_t)cct->_conf->bluefs_min_log_runway) { dout(10) << __func__ << " allocating more log runway (0x" << std::hex << runway << std::dec << " remaining)" << dendl; @@ -2219,6 +2220,7 @@ int BlueFS::_flush_and_sync_log(std::unique_lock& l, ceph_assert(r == 0); vselector->add_usage(log_writer->file->vselector_hint, log_writer->file->fnode); log_t.op_file_update(log_writer->file->fnode); + just_expanded_log = true; } bufferlist bl; @@ -2231,6 +2233,10 @@ int BlueFS::_flush_and_sync_log(std::unique_lock& l, logger->inc(l_bluefs_logged_bytes, bl.length()); + if (just_expanded_log) { + ceph_assert(bl.length() <= runway); // if we write this, we will have an unrecoverable data loss + } + log_writer->append(bl); log_t.clear();