From b06bcf99f50cf7db5856eb1f6cd56100a0d0bbbc Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Mon, 9 Aug 2021 18:18:35 +0300 Subject: [PATCH] os/bluestore: account for alignment with max_blob_size when splitting write I/O into chunks. Without the fix the following write seq: 0~4M 4096~4M produces tons of deferred writes at the second stage. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b6809e8464bc4..fbc448e32256f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -13849,12 +13849,16 @@ void BlueStore::_do_write_big( uint64_t prefer_deferred_size_snapshot = prefer_deferred_size.load(); while (length > 0) { bool new_blob = false; - uint32_t l = std::min(max_bsize, length); BlobRef b; uint32_t b_off = 0; + uint32_t l = 0; //attempting to reuse existing blob if (!wctx->compress) { + // enforce target blob alignment with max_bsize + l = max_bsize - p2phase(offset, max_bsize); + l = std::min(uint64_t(l), length); + auto end = o->extent_map.extent_map.end(); dout(20) << __func__ << " may be defer: 0x" << std::hex @@ -14003,6 +14007,8 @@ void BlueStore::_do_write_big( } } while (b == nullptr && any_change); } else { + // trying to utilize as longer chunk as permitted in case of compression. + l = std::min(max_bsize, length); o->extent_map.punch_hole(c, offset, l, &wctx->old_extents); } // if (!wctx->compress) -- 2.39.5