]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: introduce method to estimate BlueFS transaction size
authorIgor Fedotov <igor.fedotov@croit.io>
Tue, 8 Nov 2022 15:16:21 +0000 (18:16 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Thu, 26 Jan 2023 11:16:59 +0000 (14:16 +0300)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
(cherry picked from commit 05478fc46bc6437e8e57642a5ffdedde851f08f3)

src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index 80aa986d2373f4d7497da7e9167fe2ba0b6e9569..1aec2cb3b2f8a6654845d4884ce92e2f1864d73b 100644 (file)
@@ -2275,6 +2275,17 @@ void BlueFS::invalidate_cache(FileRef f, uint64_t offset, uint64_t length)
   }
 }
 
+
+uint64_t BlueFS::_estimate_transaction_size(bluefs_transaction_t* t)
+{
+  uint64_t max_alloc_size = std::max(alloc_size[BDEV_WAL],
+                                    std::max(alloc_size[BDEV_DB],
+                                             alloc_size[BDEV_SLOW]));
+
+  // conservative estimate for final encoded size
+  return round_up_to(t->op_bl.length() + super.block_size * 2, max_alloc_size);
+}
+
 uint64_t BlueFS::_estimate_log_size_N()
 {
   std::lock_guard nl(nodes.lock);
@@ -2587,13 +2598,7 @@ void BlueFS::_compact_log_async_LD_LNF_D() //also locks FW for new_writer
   // log can be used to write to, ops in log will be continuation of captured state
   log.lock.unlock();
 
-  uint64_t max_alloc_size = std::max(alloc_size[BDEV_WAL],
-                                    std::max(alloc_size[BDEV_DB],
-                                             alloc_size[BDEV_SLOW]));
-
-  // conservative estimate for final encoded size
-  new_log_jump_to = round_up_to(t.op_bl.length() + super.block_size * 2,
-                                max_alloc_size);
+  new_log_jump_to = _estimate_transaction_size(&t);
   //newly constructed log head will jump to what we had before
   t.op_jump(seq_now, new_log_jump_to);
 
@@ -2675,13 +2680,14 @@ void BlueFS::_compact_log_async_LD_LNF_D() //also locks FW for new_writer
   ceph_assert(old_is_comp);
 }
 
-void BlueFS::_pad_bl(bufferlist& bl)
+void BlueFS::_pad_bl(bufferlist& bl, uint64_t pad_size)
 {
-  uint64_t partial = bl.length() % super.block_size;
+  pad_size = std::max(pad_size, uint64_t(super.block_size));
+  uint64_t partial = bl.length() % pad_size;
   if (partial) {
     dout(10) << __func__ << " padding with 0x" << std::hex
-            << super.block_size - partial << " zeros" << std::dec << dendl;
-    bl.append_zero(super.block_size - partial);
+            << pad_size - partial << " zeros" << std::dec << dendl;
+    bl.append_zero(pad_size - partial);
   }
 }
 
index 5ff828023db7081d07fc08c7247503ba2dfa5e95..95518103865a129cbb9bf958dae1bd0fc4a01daa 100644 (file)
@@ -404,7 +404,8 @@ private:
   void _init_alloc();
   void _stop_alloc();
 
-  void _pad_bl(ceph::buffer::list& bl);  ///< pad ceph::buffer::list to block size w/ zeros
+  ///< pad ceph::buffer::list to max(block size, pad_size) w/ zeros
+  void _pad_bl(ceph::buffer::list& bl, uint64_t pad_size = 0);
 
   uint64_t _get_used(unsigned id) const;
   uint64_t _get_total(unsigned id) const;
@@ -447,6 +448,7 @@ private:
                               int64_t available_runway);
   int _flush_and_sync_log_LD(uint64_t want_seq = 0);
 
+  uint64_t _estimate_transaction_size(bluefs_transaction_t* t);
   uint64_t _estimate_log_size_N();
   bool _should_start_compact_log_L_N();