Skip to content

Commit f80ba9d

Browse files
Merge pull request ceph#64564 from JonBailey1993/ceph_test_rados_io_sequence_set_optimisations_earlier
test/osd: Move initialisation of overwrites and optimisation earlier in ceph_test_rados_io_sequence Reviewed-by: Ronen Friedman <[email protected]>
2 parents 6331689 + 13b64bd commit f80ba9d

File tree

10 files changed

+124
-40
lines changed

10 files changed

+124
-40
lines changed

src/common/io_exerciser/RadosIo.cc

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio,
6363
int rc;
6464
rc = rados.ioctx_create(pool.c_str(), io);
6565
ceph_assert(rc == 0);
66-
allow_ec_overwrites(true);
67-
if (ec_optimizations) {
68-
allow_ec_optimizations();
69-
}
7066
}
7167

7268
RadosIo::~RadosIo() {}
@@ -90,28 +86,6 @@ void RadosIo::wait_for_io(int count) {
9086
}
9187
}
9288

93-
void RadosIo::allow_ec_overwrites(bool allow) {
94-
int rc;
95-
bufferlist inbl, outbl;
96-
std::string cmdstr = "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool +
97-
"\", \
98-
\"var\": \"allow_ec_overwrites\", \"val\": \"" +
99-
(allow ? "true" : "false") + "\"}";
100-
rc = rados.mon_command(cmdstr, inbl, &outbl, nullptr);
101-
ceph_assert(rc == 0);
102-
}
103-
104-
void RadosIo::allow_ec_optimizations()
105-
{
106-
int rc;
107-
bufferlist inbl, outbl;
108-
std::string cmdstr =
109-
"{\"prefix\": \"osd pool set\", \"pool\": \"" + pool + "\", \
110-
\"var\": \"allow_ec_optimizations\", \"val\": \"true\"}";
111-
rc = rados.mon_command(cmdstr, inbl, &outbl, nullptr);
112-
ceph_assert(rc == 0);
113-
}
114-
11589
template <int N>
11690
RadosIo::AsyncOpInfo<N>::AsyncOpInfo(const std::array<uint64_t, N>& offset,
11791
const std::array<uint64_t, N>& length)
@@ -197,8 +171,14 @@ void RadosIo::applyIoOp(IoOp& op) {
197171

198172
case OpType::Consistency: {
199173
start_io();
174+
ceph_assert(cc);
200175
bool is_consistent =
201-
cc->single_read_and_check_consistency(oid, block_size, 0, 0);
176+
cc->single_read_and_check_consistency(oid, block_size, 0, 0);
177+
if (!is_consistent) {
178+
std::stringstream strstream;
179+
cc->print_results(strstream);
180+
std::cerr << strstream.str() << std::endl;
181+
}
202182
ceph_assert(is_consistent);
203183
finish_io();
204184
break;

src/common/json/OSDStructures.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ void OSDPoolGetReply::decode_json(JSONObj* obj) {
6969
JSONDecoder::decode_json("allow_ec_optimizations", allow_ec_optimizations, obj);
7070
}
7171

72+
void OSDPoolSetRequest::dump(Formatter* f) const {
73+
encode_json("prefix", "osd pool set", f);
74+
encode_json("pool", pool, f);
75+
encode_json("var", var, f);
76+
encode_json("val", val, f);
77+
encode_json("yes_i_really_mean_it", yes_i_really_mean_it, f);
78+
}
79+
80+
void OSDPoolSetRequest::decode_json(JSONObj* obj) {
81+
JSONDecoder::decode_json("pool", pool, obj);
82+
JSONDecoder::decode_json("var", var, obj);
83+
JSONDecoder::decode_json("val", val, obj);
84+
JSONDecoder::decode_json("yes_i_really_mean_it", yes_i_really_mean_it, obj);
85+
}
86+
7287
void OSDECProfileGetRequest::dump(Formatter* f) const {
7388
encode_json("prefix", "osd erasure-code-profile get", f);
7489
encode_json("name", name, f);

src/common/json/OSDStructures.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ struct OSDPoolGetReply {
5555
void decode_json(JSONObj* obj);
5656
};
5757

58+
struct OSDPoolSetRequest {
59+
std::string pool;
60+
std::string var;
61+
std::optional<std::string> val;
62+
std::optional<bool> yes_i_really_mean_it = std::nullopt;
63+
64+
void dump(Formatter* f) const;
65+
void decode_json(JSONObj* obj);
66+
};
67+
5868
struct OSDECProfileGetRequest {
5969
std::string name;
6070
std::string format = "json";

src/erasure-code/consistency/ConsistencyChecker.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ECReader.h"
66
#include "ECEncoder.h"
77
#include "ECEncoderSwitch.h"
8+
#include "osd/ECUtil.h"
89

910
using ConsistencyChecker = ceph::consistency::ConsistencyChecker;
1011

@@ -115,6 +116,30 @@ bool ConsistencyChecker::check_object_consistency(const std::string& oid,
115116
return false;
116117
}
117118

119+
// Encode always returns 4k aligned data
120+
// A client read will always return parity with the same size as shard 0
121+
// We confirm the encoded data is the same or larger than the client read
122+
ceph_assert(outbl->length() >= data_and_parity.second.length());
123+
// We check the difference is not larger than the page size multipled by the
124+
// number of parities
125+
ceph_assert(outbl->length() - data_and_parity.second.length()
126+
<= (encoder.get_m() * encoder.get_chunk_size()) - encoder.get_m());
127+
// We truncate the encoded parity to the size of the client read for comparison
128+
if (outbl->length() != data_and_parity.second.length())
129+
{
130+
const int aligned_shard_length = outbl->length() / encoder.get_m();
131+
const int shard_data_length = data_and_parity.second.length()
132+
/ encoder.get_m();
133+
ceph::bufferlist newdata;
134+
for (int i = 0; i < encoder.get_m(); i++)
135+
{
136+
ceph::bufferlist bl;
137+
bl.substr_of(*outbl, i * aligned_shard_length, shard_data_length);
138+
newdata.append(bl);
139+
}
140+
outbl = std::move(newdata);
141+
}
142+
118143
return buffers_match(outbl.value(), data_and_parity.second);
119144
}
120145

src/erasure-code/consistency/ECEncoder.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ int ECEncoder<SInfo>::get_m()
198198
{
199199
return stripe_info->get_m();
200200
}
201+
202+
/**
203+
* Return chunksize for the stripe
204+
*
205+
* @returns int Chunksize for the stripe
206+
*/
207+
template <typename SInfo>
208+
int ECEncoder<SInfo>::get_chunk_size()
209+
{
210+
return stripe_info->get_chunk_size();
211+
}
201212
}
202213
}
203214

src/erasure-code/consistency/ECEncoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ECEncoder {
2929
std::optional<ceph::bufferlist> do_encode(ceph::bufferlist inbl);
3030
int get_k(void);
3131
int get_m(void);
32+
int get_chunk_size(void);
3233
};
3334
}
3435
}

src/erasure-code/consistency/ECEncoderSwitch.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ int ECEncoderSwitch::get_m()
5757
return encoder_legacy.get_m();
5858
}
5959
}
60+
61+
/**
62+
* Return chunksize for the stripe from the correct version of the encoder
63+
*
64+
* @returns int Chunksize for stripe
65+
*/
66+
int ECEncoderSwitch::get_chunk_size()
67+
{
68+
if (optimizations_enabled) {
69+
return encoder_optimized.get_chunk_size();
70+
} else {
71+
return encoder_legacy.get_chunk_size();
72+
}
73+
}

src/erasure-code/consistency/ECEncoderSwitch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ECEncoderSwitch {
2626
std::optional<ceph::bufferlist> do_encode(ceph::bufferlist inbl);
2727
int get_k(void);
2828
int get_m(void);
29+
int get_chunk_size(void);
2930
};
3031
}
3132
}

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
794794
bool allow_pool_deep_scrubbing,
795795
bool allow_pool_scrubbing,
796796
bool test_recovery,
797-
bool disable_pool_ec_optimizations)
797+
bool allow_pool_ec_optimizations)
798798
: ProgramOptionReader<std::string>(vm, "pool"),
799799
rados(rados),
800800
dry_run(dry_run),
@@ -803,7 +803,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
803803
allow_pool_deep_scrubbing(allow_pool_deep_scrubbing),
804804
allow_pool_scrubbing(allow_pool_scrubbing),
805805
test_recovery(test_recovery),
806-
disable_pool_ec_optimizations(disable_pool_ec_optimizations),
806+
allow_pool_ec_optimizations(allow_pool_ec_optimizations),
807807
first_use(true),
808808
sep{cct, rng, vm, rados, dry_run, first_use} {
809809
if (isForced()) {
@@ -849,9 +849,10 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
849849
}
850850

851851
if (!dry_run) {
852-
configureServices(allow_pool_autoscaling, allow_pool_balancer,
852+
configureServices(force_value.value_or(created_pool_name),
853+
allow_pool_autoscaling, allow_pool_balancer,
853854
allow_pool_deep_scrubbing, allow_pool_scrubbing,
854-
test_recovery);
855+
allow_pool_ec_optimizations, true, test_recovery);
855856

856857
setApplication(created_pool_name);
857858
}
@@ -868,7 +869,7 @@ std::string ceph::io_sequence::tester::SelectErasurePool::create() {
868869
std::string pool_name;
869870
profile = sep.select();
870871
pool_name = fmt::format("testpool-pr{}{}", profile->name,
871-
disable_pool_ec_optimizations?"_no_ec_opt":"");
872+
allow_pool_ec_optimizations?"":"_no_ec_opt");
872873

873874
ceph::messaging::osd::OSDECPoolCreateRequest pool_create_request{
874875
pool_name, "erasure", 8, 8, profile->name};
@@ -895,10 +896,13 @@ void ceph::io_sequence::tester::SelectErasurePool::setApplication(
895896
}
896897

897898
void ceph::io_sequence::tester::SelectErasurePool::configureServices(
899+
const std::string& pool_name,
898900
bool allow_pool_autoscaling,
899901
bool allow_pool_balancer,
900902
bool allow_pool_deep_scrubbing,
901903
bool allow_pool_scrubbing,
904+
bool allow_pool_ec_optimizations,
905+
bool allow_pool_ec_overwrites,
902906
bool test_recovery) {
903907
int rc;
904908
bufferlist inbl, outbl;
@@ -942,12 +946,34 @@ void ceph::io_sequence::tester::SelectErasurePool::configureServices(
942946

943947
if (!allow_pool_scrubbing) {
944948
ceph::messaging::osd::OSDSetRequest no_scrub_request{"noscrub",
945-
std::nullopt};
949+
std::nullopt};
946950
rc = send_mon_command(no_scrub_request, rados, "OSDSetRequest", inbl,
947951
&outbl, formatter.get());
948952
ceph_assert(rc == 0);
949953
}
950954

955+
if (allow_pool_ec_optimizations) {
956+
ceph::messaging::osd::OSDPoolSetRequest
957+
allow_ec_optimisations_request{pool_name,
958+
"allow_ec_optimizations",
959+
"true",
960+
std::nullopt};
961+
rc = send_mon_command(allow_ec_optimisations_request, rados,
962+
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
963+
ceph_assert(rc == 0);
964+
}
965+
966+
if (allow_pool_ec_overwrites) {
967+
ceph::messaging::osd::OSDPoolSetRequest
968+
allow_ec_optimisations_request{pool_name,
969+
"allow_ec_overwrites",
970+
"true",
971+
std::nullopt};
972+
rc = send_mon_command(allow_ec_optimisations_request, rados,
973+
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
974+
ceph_assert(rc == 0);
975+
}
976+
951977
if (test_recovery) {
952978
ceph::messaging::config::ConfigSetRequest bluestore_debug_request{
953979
"global", "bluestore_debug_inject_read_err", "true", std::nullopt};
@@ -1105,7 +1131,7 @@ ceph::io_sequence::tester::TestRunner::TestRunner(
11051131
vm.contains("allow_pool_deep_scrubbing"),
11061132
vm.contains("allow_pool_scrubbing"),
11071133
vm.contains("testrecovery"),
1108-
vm.contains("disable_pool_ec_optimizations")},
1134+
!vm.contains("disable_pool_ec_optimizations")},
11091135
snt{rng, vm, "threads", true},
11101136
ssr{vm} {
11111137
dout(0) << "Test using seed " << seed << dendl;
@@ -1127,7 +1153,6 @@ ceph::io_sequence::tester::TestRunner::TestRunner(
11271153
allow_pool_balancer = vm.contains("allow_pool_balancer");
11281154
allow_pool_deep_scrubbing = vm.contains("allow_pool_deep_scrubbing");
11291155
allow_pool_scrubbing = vm.contains("allow_pool_scrubbing");
1130-
disable_pool_ec_optimizations = vm.contains("disable_pool_ec_optimizations");
11311156

11321157
if (testrecovery && (num_objects > 1)) {
11331158
throw std::invalid_argument("testrecovery option not allowed if parallel is"

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
389389
bool allow_pool_deep_scrubbing,
390390
bool allow_pool_scrubbing,
391391
bool test_recovery,
392-
bool disable_pool_ec_optimizations);
392+
bool allow_pool_ec_optimizations);
393393
const std::string select() override;
394394
std::string create();
395395

@@ -400,7 +400,7 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
400400
}
401401
inline bool get_allow_pool_scrubbing() { return allow_pool_scrubbing; }
402402
inline bool get_allow_pool_ec_optimizations() {
403-
return !disable_pool_ec_optimizations;
403+
return allow_pool_ec_optimizations;
404404
}
405405
inline std::optional<Profile> getProfile() { return profile; }
406406

@@ -413,18 +413,21 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
413413
bool allow_pool_deep_scrubbing;
414414
bool allow_pool_scrubbing;
415415
bool test_recovery;
416-
bool disable_pool_ec_optimizations;
416+
bool allow_pool_ec_optimizations;
417417

418418
bool first_use;
419419

420420
SelectErasureProfile sep;
421421

422422
std::optional<Profile> profile;
423423

424-
void configureServices(bool allow_pool_autoscaling,
424+
void configureServices(const std::string& pool_name,
425+
bool allow_pool_autoscaling,
425426
bool allow_pool_balancer,
426427
bool allow_pool_deep_scrubbing,
427428
bool allow_pool_scrubbing,
429+
bool disable_pool_ec_optimizations,
430+
bool allow_pool_ec_overwrites,
428431
bool test_recovery);
429432

430433
void setApplication(const std::string& pool_name);
@@ -515,7 +518,6 @@ class TestRunner {
515518
bool allow_pool_balancer;
516519
bool allow_pool_deep_scrubbing;
517520
bool allow_pool_scrubbing;
518-
bool disable_pool_ec_optimizations;
519521

520522
bool show_sequence;
521523
bool show_help;

0 commit comments

Comments
 (0)