Skip to content

Commit 65ad90a

Browse files
Jake SquelchJakesquelch
authored andcommitted
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 <[email protected]>
1 parent dfdc970 commit 65ad90a

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

qa/standalone/erasure-code/test-erasure-code.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@ function TEST_rados_put_get_shec() {
249249
ceph osd erasure-code-profile rm $profile
250250
}
251251

252+
function chunk_size() {
253+
local chunk_size=$(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit)
254+
if [ "$chunk_size" -eq 0 ]; then
255+
local ec_opt=$(ceph-conf --show-config-value osd_pool_default_flag_ec_optimizations)
256+
if [ "$ec_opt" = "true" ]; then
257+
chunk_size=$((16 * 1024))
258+
else
259+
chunk_size=$((4 * 1024))
260+
fi
261+
fi
262+
echo $chunk_size
263+
}
264+
252265
function TEST_alignment_constraints() {
253266
local payload=ABC
254267
echo "$payload" > $dir/ORIGINAL
@@ -257,7 +270,7 @@ function TEST_alignment_constraints() {
257270
# imposed by the stripe width
258271
# See http://tracker.ceph.com/issues/8622
259272
#
260-
local stripe_unit=$(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit)
273+
local stripe_unit=$(chunk_size)
261274
eval local $(ceph osd erasure-code-profile get myprofile | grep k=)
262275
local block_size=$((stripe_unit * k - 1))
263276
dd if=/dev/zero of=$dir/ORIGINAL bs=$block_size count=2
@@ -266,10 +279,6 @@ function TEST_alignment_constraints() {
266279
rm $dir/ORIGINAL
267280
}
268281

269-
function chunk_size() {
270-
echo $(ceph-conf --show-config-value osd_pool_erasure_code_stripe_unit)
271-
}
272-
273282
#
274283
# By default an object will be split in two (k=2) with the first part
275284
# of the object in the first OSD of the up set and the second part in
@@ -333,5 +342,5 @@ function TEST_chunk_mapping() {
333342
main test-erasure-code "$@"
334343

335344
# Local Variables:
336-
# compile-command: "cd ../.. ; make -j4 && test/erasure-code/test-erasure-code.sh"
337-
# End:
345+
# compile-command: "cd ../..; make -j4 && test/erasure-code/test-erasure-code.sh"
346+
# End:

src/common/options/mon.yaml.in

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ options:
2121
stripe for erasure coded pools. Every object of size S
2222
will be stored as N stripes, with each data chunk
2323
receiving ``stripe unit`` bytes. Each stripe of ``N *
24-
stripe unit`` bytes will be encoded/decoded
25-
individually. This option can is overridden by the
26-
``stripe_unit`` setting in an erasure code profile.
27-
default: 4_K
24+
stripe unit`` bytes will be encoded/decoded individually.
25+
A value of 0 causes the code to select either a 4KB or 16KB
26+
stripe_unit depending on whether ``allow_ec_optimizations``
27+
is enabled. If enabled, ``stripe unit`` is set to 16KB, otherwise it
28+
is set to 4KB. This option can be overridden by the ``stripe_unit``
29+
setting in an erasure code profile.
30+
long_desc: A value of 0 causes the code to select either a 4KB or 16KB stripe_unit
31+
depending on whether allow_ec_optimizations is enabled.
32+
default: 0
2833
services:
2934
- mon
3035
- name: osd_pool_default_crimson

src/mon/OSDMonitor.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7832,6 +7832,17 @@ int OSDMonitor::prepare_pool_stripe_width(const unsigned pool_type,
78327832
break;
78337833
uint32_t data_chunks = erasure_code->get_data_chunk_count();
78347834
uint32_t stripe_unit = g_conf().get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit");
7835+
7836+
if (stripe_unit == 0) {
7837+
if (((erasure_code->get_supported_optimizations() &
7838+
ErasureCodeInterface::FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED) != 0) &&
7839+
(cct->_conf.get_val<bool>("osd_pool_default_flag_ec_optimizations"))) {
7840+
stripe_unit = 16 * 1024;
7841+
} else {
7842+
stripe_unit = 4 * 1024;
7843+
}
7844+
}
7845+
78357846
auto it = profile.find("stripe_unit");
78367847
if (it != profile.end()) {
78377848
string err_str;

src/test/erasure-code/TestErasureCodeLrc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ TEST(ErasureCodeLrc, encode_decode)
617617
profile["layers"] = description_string;
618618
EXPECT_EQ(0, lrc.init(profile, &cerr));
619619
EXPECT_EQ(4U, lrc.get_data_chunk_count());
620-
unsigned int chunk_size = g_conf().get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit");
620+
unsigned int chunk_size = 4096;
621621
unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size;
622622
EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width));
623623
shard_id_set want_to_encode;
@@ -757,7 +757,7 @@ TEST(ErasureCodeLrc, encode_decode_2)
757757
profile["layers"] = description_string;
758758
EXPECT_EQ(0, lrc.init(profile, &cerr));
759759
EXPECT_EQ(4U, lrc.get_data_chunk_count());
760-
unsigned int chunk_size = g_conf().get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit");
760+
unsigned int chunk_size = 4096;
761761
unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size;
762762
EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width));
763763
shard_id_set want_to_encode;

0 commit comments

Comments
 (0)