From baadb760a616a0f809e23d9fd5c4ca574bee6697 Mon Sep 17 00:00:00 2001 From: Laura Flores Date: Fri, 6 May 2022 17:14:10 +0000 Subject: [PATCH] os/bluestore: turn bluestore zero block detection off by default This commit adds a new global config option called `bluestore_zero_block_detection`. This option is used at a dev level to skip zero bufferlist writes in large-scale testing scenarios. Store tests originally written for the BlueStore zero block detection feature now account for the global config option; these tests will only run if `bluestore_zero_block_detection` is set to "true". Fixes: https://tracker.ceph.com/issues/55521 Signed-off-by: Laura Flores (cherry picked from commit 4a8180952c292aa2f8ee656685fcdddc3f0f0a4f) --- src/common/options/global.yaml.in | 11 +++++++++++ src/os/bluestore/BlueStore.cc | 10 +++++----- src/test/objectstore/store_test.cc | 20 ++++++++++++-------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index 1e9fd067f4c48..3bba588296951 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -5418,6 +5418,17 @@ options: flags: - runtime with_legacy: true +- name: bluestore_zero_block_detection + type: bool + level: dev + desc: punch holes instead of writing zeros + long_desc: Intended for large-scale synthetic testing. Currently this is implemented + with punch hole semantics, affecting the logical extent map of the object. This does + not interact well with some RBD and CephFS features. + default: false + flags: + - runtime + with_legacy: true - name: kstore_max_ops type: uint level: advanced diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index ce066fa72952b..f3a4f76ecdb9b 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -14581,7 +14581,7 @@ void BlueStore::_do_write_small( o->extent_map.punch_hole(c, offset, length, &wctx->old_extents); // Zero detection -- small block - if (!bl.is_zero()) { + if (!cct->_conf->bluestore_zero_block_detection || !bl.is_zero()) { BlobRef b = c->new_blob(); _pad_zeros(&bl, &b_off0, min_alloc_size); wctx->write(offset, b, alloc_len, b_off0, bl, b_off, length, false, true); @@ -14820,7 +14820,7 @@ void BlueStore::_do_write_small( o->extent_map.punch_hole(c, offset, length, &wctx->old_extents); // Zero detection -- small block - if (!bl.is_zero()) { + if (!cct->_conf->bluestore_zero_block_detection || !bl.is_zero()) { _pad_zeros(&bl, &b_off0, chunk_size); dout(20) << __func__ << " reuse blob " << *b << std::hex @@ -14882,7 +14882,7 @@ void BlueStore::_do_write_small( o->extent_map.punch_hole(c, offset, length, &wctx->old_extents); // Zero detection -- small block - if (!bl.is_zero()) { + if (!cct->_conf->bluestore_zero_block_detection || !bl.is_zero()) { uint64_t chunk_size = b->get_blob().get_chunk_size(block_size); _pad_zeros(&bl, &b_off0, chunk_size); @@ -14938,7 +14938,7 @@ void BlueStore::_do_write_small( o->extent_map.punch_hole(c, offset, length, &wctx->old_extents); // Zero detection -- small block - if (!bl.is_zero()) { + if (!cct->_conf->bluestore_zero_block_detection || !bl.is_zero()) { // new blob. BlobRef b = c->new_blob(); _pad_zeros(&bl, &b_off0, block_size); @@ -15271,7 +15271,7 @@ void BlueStore::_do_write_big( blp.copy(l, t); // Zero detection -- big block - if (!t.is_zero()) { + if (!cct->_conf->bluestore_zero_block_detection || !t.is_zero()) { wctx->write(offset, b, l, b_off, t, b_off, l, false, new_blob); dout(20) << __func__ << " schedule write big: 0x" diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 64e6e60c0cdee..e45d5543a108c 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -7259,8 +7259,9 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwrite) { } TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionSmallAppend) { - if (string(GetParam()) != "bluestore") { - return; + CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get(); + if (string(GetParam()) != "bluestore" || !cct->_conf->bluestore_zero_block_detection) { + GTEST_SKIP() << "not bluestore or bluestore_zero_block_detection=false, skipping"; } size_t block_size = 65536; @@ -7334,8 +7335,9 @@ TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionSmallAppend) { } TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionSmallOverwrite) { - if (string(GetParam()) != "bluestore") { - return; + CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get(); + if (string(GetParam()) != "bluestore" || !cct->_conf->bluestore_zero_block_detection) { + GTEST_SKIP() << "not bluestore or bluestore_zero_block_detection=false, skipping"; } if (smr) { cout << "SKIP" << std::endl; @@ -7435,8 +7437,9 @@ TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionSmallOverwrite) { } TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionBigAppend) { - if (string(GetParam()) != "bluestore") { - return; + CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get(); + if (string(GetParam()) != "bluestore" || !cct->_conf->bluestore_zero_block_detection) { + GTEST_SKIP() << "not bluestore or bluestore_zero_block_detection=false, skipping"; } size_t block_size = 4096; @@ -7513,8 +7516,9 @@ TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionBigAppend) { } TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionBigOverwrite) { - if (string(GetParam()) != "bluestore") { - return; + CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get(); + if (string(GetParam()) != "bluestore" || !cct->_conf->bluestore_zero_block_detection) { + GTEST_SKIP() << "not bluestore or bluestore_zero_block_detection=false, skipping"; } if (smr) { cout << "SKIP" << std::endl; -- 2.39.5