From: Jake Squelch Date: Fri, 8 Aug 2025 10:10:34 +0000 (+0100) Subject: mon: default chunk size change X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=65ad90aebc5e68154e430e091e71f1c2a9e66762;p=ceph.git mon: default chunk size change Changed chunk size value depending if EC optimisation was ON/OFF and if the plugin optimisations were supported. Signed-off-by: Jake Squelch --- diff --git a/qa/standalone/erasure-code/test-erasure-code.sh b/qa/standalone/erasure-code/test-erasure-code.sh index b9315123365..bb93fc91f6e 100755 --- a/qa/standalone/erasure-code/test-erasure-code.sh +++ b/qa/standalone/erasure-code/test-erasure-code.sh @@ -249,6 +249,19 @@ function TEST_rados_put_get_shec() { ceph osd erasure-code-profile rm $profile } +function chunk_size() { + local chunk_size=$(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit) + if [ "$chunk_size" -eq 0 ]; then + local ec_opt=$(ceph-conf --show-config-value osd_pool_default_flag_ec_optimizations) + if [ "$ec_opt" = "true" ]; then + chunk_size=$((16 * 1024)) + else + chunk_size=$((4 * 1024)) + fi + fi + echo $chunk_size +} + function TEST_alignment_constraints() { local payload=ABC echo "$payload" > $dir/ORIGINAL @@ -257,7 +270,7 @@ function TEST_alignment_constraints() { # imposed by the stripe width # See http://tracker.ceph.com/issues/8622 # - local stripe_unit=$(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit) + local stripe_unit=$(chunk_size) eval local $(ceph osd erasure-code-profile get myprofile | grep k=) local block_size=$((stripe_unit * k - 1)) dd if=/dev/zero of=$dir/ORIGINAL bs=$block_size count=2 @@ -266,10 +279,6 @@ function TEST_alignment_constraints() { rm $dir/ORIGINAL } -function chunk_size() { - echo $(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit) -} - # # By default an object will be split in two (k=2) with the first part # of the object in the first OSD of the up set and the second part in @@ -333,5 +342,5 @@ function TEST_chunk_mapping() { main test-erasure-code "$@" # Local Variables: -# compile-command: "cd ../.. ; make -j4 && test/erasure-code/test-erasure-code.sh" -# End: +# compile-command: "cd ../..; make -j4 && test/erasure-code/test-erasure-code.sh" +# End: \ No newline at end of file diff --git a/src/common/options/mon.yaml.in b/src/common/options/mon.yaml.in index 2c337fcea70..dff5ecfff1f 100644 --- a/src/common/options/mon.yaml.in +++ b/src/common/options/mon.yaml.in @@ -21,10 +21,15 @@ options: stripe for erasure coded pools. Every object of size S will be stored as N stripes, with each data chunk receiving ``stripe unit`` bytes. Each stripe of ``N * - stripe unit`` bytes will be encoded/decoded - individually. This option can is overridden by the - ``stripe_unit`` setting in an erasure code profile. - default: 4_K + stripe unit`` bytes will be encoded/decoded individually. + A value of 0 causes the code to select either a 4KB or 16KB + stripe_unit depending on whether ``allow_ec_optimizations`` + is enabled. If enabled, ``stripe unit`` is set to 16KB, otherwise it + is set to 4KB. This option can be overridden by the ``stripe_unit`` + setting in an erasure code profile. + long_desc: A value of 0 causes the code to select either a 4KB or 16KB stripe_unit + depending on whether allow_ec_optimizations is enabled. + default: 0 services: - mon - name: osd_pool_default_crimson diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index bd7f60594b3..f9cbfe2616d 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7832,6 +7832,17 @@ int OSDMonitor::prepare_pool_stripe_width(const unsigned pool_type, break; uint32_t data_chunks = erasure_code->get_data_chunk_count(); uint32_t stripe_unit = g_conf().get_val("osd_pool_erasure_code_stripe_unit"); + + if (stripe_unit == 0) { + if (((erasure_code->get_supported_optimizations() & + ErasureCodeInterface::FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED) != 0) && + (cct->_conf.get_val("osd_pool_default_flag_ec_optimizations"))) { + stripe_unit = 16 * 1024; + } else { + stripe_unit = 4 * 1024; + } + } + auto it = profile.find("stripe_unit"); if (it != profile.end()) { string err_str; diff --git a/src/test/erasure-code/TestErasureCodeLrc.cc b/src/test/erasure-code/TestErasureCodeLrc.cc index 9ffd9a7e004..e20943d515c 100644 --- a/src/test/erasure-code/TestErasureCodeLrc.cc +++ b/src/test/erasure-code/TestErasureCodeLrc.cc @@ -617,7 +617,7 @@ TEST(ErasureCodeLrc, encode_decode) profile["layers"] = description_string; EXPECT_EQ(0, lrc.init(profile, &cerr)); EXPECT_EQ(4U, lrc.get_data_chunk_count()); - unsigned int chunk_size = g_conf().get_val("osd_pool_erasure_code_stripe_unit"); + unsigned int chunk_size = 4096; unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size; EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width)); shard_id_set want_to_encode; @@ -757,7 +757,7 @@ TEST(ErasureCodeLrc, encode_decode_2) profile["layers"] = description_string; EXPECT_EQ(0, lrc.init(profile, &cerr)); EXPECT_EQ(4U, lrc.get_data_chunk_count()); - unsigned int chunk_size = g_conf().get_val("osd_pool_erasure_code_stripe_unit"); + unsigned int chunk_size = 4096; unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size; EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width)); shard_id_set want_to_encode;