]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
bluestore/BlueFS: prevent fragmented bufferlists in log writes
authorPiotr Dałek <piotr.dalek@corp.ovh.com>
Thu, 26 Apr 2018 07:45:37 +0000 (09:45 +0200)
committerPiotr Dałek <piotr.dalek@corp.ovh.com>
Fri, 27 Apr 2018 07:06:01 +0000 (09:06 +0200)
Instead of adding new bufferptrs into log writer's bufferlist,
encode required data using single, pre-aligned bufferptr. This
prevents bufferlist rebuilds during aio_write to WAL which is way
more costly than explicitly reserving buffer and writing to that.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/bluefs_types.cc

index 567262c2fbd197c495b1fe8e3587e01571300214..2f24d588fa76b555594cce9a80d43a81d4350bb6 100644 (file)
@@ -1537,10 +1537,13 @@ int BlueFS::_flush_and_sync_log(std::unique_lock<std::mutex>& l,
   }
 
   bufferlist bl;
+  bl.reserve(super.block_size);
   encode(log_t, bl);
-
   // pad to block boundary
-  _pad_bl(bl);
+  size_t realign = super.block_size - (bl.length() % super.block_size);
+  if (realign && realign != super.block_size)
+    bl.append_zero(realign);
+
   logger->inc(l_bluefs_logged_bytes, bl.length());
 
   log_writer->append(bl);
index d2e6b39c82efe5a3ad2d97465db961ea5667d9d0..439f20fbca812bd1e2e9f67ae5e7faecba71664e 100644 (file)
@@ -141,7 +141,13 @@ void bluefs_transaction_t::encode(bufferlist& bl) const
   ENCODE_START(1, 1, bl);
   encode(uuid, bl);
   encode(seq, bl);
-  encode(op_bl, bl);
+  // not using bufferlist encode method, as it merely copies the bufferptr and not
+  // contents, meaning we're left with fragmented target bl
+  __u32 len = op_bl.length();
+  encode(len, bl);
+  for (auto& it : op_bl.buffers()) {
+    bl.append(it.c_str(),  it.length());
+  }
   encode(crc, bl);
   ENCODE_FINISH(bl);
 }