]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Added check that protects against corrupting BlueFS replay log
authorAdam Kupczyk <akupczyk@redhat.com>
Mon, 8 Jun 2020 10:40:19 +0000 (12:40 +0200)
committerAdam Kupczyk <akupczyk@redhat.com>
Tue, 22 Dec 2020 14:53:51 +0000 (15:53 +0100)
This fixes https://tracker.ceph.com/issues/46194

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit d10a9602fe0ac6dfa5fde9c12dbcf713c65f6c7e)

src/os/bluestore/BlueFS.cc

index 6e45821965d3536ae8ce3ebe7d265e52278fb139..3575953a56a7229be0eb49106cf197362b15736c 100644 (file)
@@ -2204,6 +2204,7 @@ int BlueFS::_flush_and_sync_log(std::unique_lock<ceph::mutex>& 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<ceph::mutex>& 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<ceph::mutex>& 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();