Skip to content

Commit 3703bfc

Browse files
Merge pull request ceph#62747 from bill-scales/issue70844
test: add replica pool support to ceph_test_rados_io_sequence Reviewed-by: Ronen Friedman <[email protected]> Reviewed-by: Connor Fawcett <[email protected]>
2 parents eddd4e3 + 1654b8f commit 3703bfc

File tree

8 files changed

+133
-44
lines changed

8 files changed

+133
-44
lines changed

src/common/io_exerciser/RadosIo.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio,
4646
const std::string& pool, const std::string& oid,
4747
const std::optional<std::vector<int>>& cached_shard_order,
4848
uint64_t block_size, int seed, int threads, ceph::mutex& lock,
49-
ceph::condition_variable& cond, bool ec_optimizations)
49+
ceph::condition_variable& cond, bool is_replicated_pool,
50+
bool ec_optimizations)
5051
: Model(oid, block_size),
5152
rados(rados),
5253
asio(asio),
5354
om(std::make_unique<ObjectModel>(oid, block_size, seed)),
5455
db(data_generation::DataGenerator::create_generator(
5556
data_generation::GenerationType::HeaderedSeededRandom, *om)),
56-
cc(std::make_unique<ConsistencyChecker>(rados, asio, pool)),
5757
pool(pool),
5858
cached_shard_order(cached_shard_order),
5959
threads(threads),
@@ -63,6 +63,9 @@ 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+
if (!is_replicated_pool) {
67+
cc = std::make_unique<ConsistencyChecker>(rados, asio, pool);
68+
}
6669
}
6770

6871
RadosIo::~RadosIo() {}

src/common/io_exerciser/RadosIo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class RadosIo : public Model {
4848
const std::string& pool, const std::string& oid,
4949
const std::optional<std::vector<int>>& cached_shard_order,
5050
uint64_t block_size, int seed, int threads, ceph::mutex& lock,
51-
ceph::condition_variable& cond, bool ec_optimizations);
51+
ceph::condition_variable& cond, bool is_replicated_pool,
52+
bool ec_optimizations);
5253

5354
~RadosIo();
5455

src/common/json/OSDStructures.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,36 @@ void OSDPoolGetRequest::decode_json(JSONObj* obj) {
6060
}
6161

6262
void OSDPoolGetReply::dump(Formatter* f) const {
63+
encode_json("size", size, f);
64+
encode_json("min_size", min_size, f);
65+
encode_json("pg_num", pg_num, f);
66+
encode_json("pgp_num", pgp_num, f);
67+
encode_json("crush_rule", crush_rule, f);
68+
encode_json("allow_ec_overwrites", allow_ec_overwrites, f);
69+
encode_json("nodelete", nodelete, f);
70+
encode_json("nopgchange", nopgchange, f);
71+
encode_json("nosizechange", nosizechange, f);
72+
encode_json("noscrub", noscrub, f);
73+
encode_json("nodeep-scrub", nodeep_scrub, f);
6374
encode_json("erasure_code_profile", erasure_code_profile, f);
75+
encode_json("fast_read", fast_read, f);
6476
encode_json("allow_ec_optimizations", allow_ec_optimizations, f);
6577
}
6678

6779
void OSDPoolGetReply::decode_json(JSONObj* obj) {
80+
JSONDecoder::decode_json("size", size, obj);
81+
JSONDecoder::decode_json("min_size", min_size, obj);
82+
JSONDecoder::decode_json("pg_num", pg_num, obj);
83+
JSONDecoder::decode_json("pgp_num", pgp_num, obj);
84+
JSONDecoder::decode_json("crush_rule", crush_rule, obj);
85+
JSONDecoder::decode_json("allow_ec_overwrites", allow_ec_overwrites, obj);
86+
JSONDecoder::decode_json("nodelete", nodelete, obj);
87+
JSONDecoder::decode_json("nopgchange", nopgchange, obj);
88+
JSONDecoder::decode_json("nosizechange", nosizechange, obj);
89+
JSONDecoder::decode_json("noscrub", noscrub, obj);
90+
JSONDecoder::decode_json("nodeep-scrub", nodeep_scrub, obj);
6891
JSONDecoder::decode_json("erasure_code_profile", erasure_code_profile, obj);
92+
JSONDecoder::decode_json("fast_read", fast_read, obj);
6993
JSONDecoder::decode_json("allow_ec_optimizations", allow_ec_optimizations, obj);
7094
}
7195

src/common/json/OSDStructures.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,29 @@ struct OSDMapReply {
4141

4242
struct OSDPoolGetRequest {
4343
std::string pool;
44-
std::string var = "erasure_code_profile";
44+
std::string var;
4545
std::string format = "json";
4646

4747
void dump(Formatter* f) const;
4848
void decode_json(JSONObj* obj);
4949
};
5050

5151
struct OSDPoolGetReply {
52-
std::string erasure_code_profile;
53-
bool allow_ec_optimizations;
52+
std::optional<int> size;
53+
std::optional<int> min_size;
54+
std::optional<int> pg_num;
55+
std::optional<int> pgp_num;
56+
std::optional<std::string> crush_rule;
57+
std::optional<bool> allow_ec_overwrites;
58+
std::optional<bool> nodelete;
59+
std::optional<bool> nopgchange;
60+
std::optional<bool> nosizechange;
61+
std::optional<bool> noscrub;
62+
std::optional<bool> nodeep_scrub;
63+
std::optional<std::string> erasure_code_profile;
64+
std::optional<int> fast_read;
65+
std::optional<bool> allow_ec_optimizations;
66+
5467
void dump(Formatter* f) const;
5568
void decode_json(JSONObj* obj);
5669
};

src/erasure-code/consistency/RadosCommands.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int RadosCommands::get_primary_osd(const std::string& pool_name,
5454
*/
5555
bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name)
5656
{
57-
ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name, "allow_ec_optimizations"};
57+
ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name, "all"};
5858
encode_json("OSDPoolGetRequest", osd_pool_get_request, formatter.get());
5959

6060
std::ostringstream oss;
@@ -71,7 +71,7 @@ bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name
7171
ceph::messaging::osd::OSDPoolGetReply osd_pool_get_reply;
7272
osd_pool_get_reply.decode_json(&p);
7373

74-
return osd_pool_get_reply.allow_ec_optimizations;
74+
return osd_pool_get_reply.allow_ec_optimizations.value_or(false);
7575
}
7676

7777
/**
@@ -83,7 +83,7 @@ bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name
8383
*/
8484
std::string RadosCommands::get_pool_ec_profile_name(const std::string& pool_name)
8585
{
86-
ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name};
86+
ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name, "all"};
8787
encode_json("OSDPoolGetRequest", osd_pool_get_request, formatter.get());
8888

8989
std::ostringstream oss;
@@ -100,7 +100,12 @@ std::string RadosCommands::get_pool_ec_profile_name(const std::string& pool_name
100100
ceph::messaging::osd::OSDPoolGetReply osd_pool_get_reply;
101101
osd_pool_get_reply.decode_json(&p);
102102

103-
return osd_pool_get_reply.erasure_code_profile;
103+
if (!osd_pool_get_reply.erasure_code_profile) {
104+
throw std::runtime_error("No profile for given pool. "
105+
"Is it an Erasure Coded pool?");
106+
}
107+
108+
return *osd_pool_get_reply.erasure_code_profile;
104109
}
105110

106111
/**

src/erasure-code/consistency/ceph_ec_consistency_checker.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ int main(int argc, char **argv)
7171
guard.emplace(boost::asio::make_work_guard(asio));
7272
thread = make_named_thread("io_thread",[&asio] { asio.run(); });
7373

74-
auto checker = ceph::consistency::ConsistencyChecker(rados, asio, pool);
75-
checker.single_read_and_check_consistency(oid, blocksize, offset, length);
76-
checker.print_results(std::cout);
74+
try {
75+
auto checker = ceph::consistency::ConsistencyChecker(rados, asio, pool);
76+
checker.single_read_and_check_consistency(oid, blocksize, offset, length);
77+
checker.print_results(std::cout);
78+
} catch (std::runtime_error& e) {
79+
std::cerr << e.what() << std::endl;
80+
exit(1);
81+
}
7782

7883
exit(0);
7984
}

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ constexpr std::string_view usage[] = {
134134
"ceph_test_rados_io_sequence --blocksize <b> --pool <p> --object <oid>",
135135
" --objectsize <min,max> --threads <t>",
136136
"\tCustomize the test, if a pool is specified then it defines the",
137-
"\tReplica/EC configuration",
137+
"\tReplicated/EC configuration",
138138
"",
139139
"ceph_test_rados_io_sequence --listsequence",
140140
"\t Display list of supported I/O sequences",
@@ -793,6 +793,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
793793
bool allow_pool_balancer,
794794
bool allow_pool_deep_scrubbing,
795795
bool allow_pool_scrubbing,
796+
bool check_consistency,
796797
bool test_recovery,
797798
bool allow_pool_ec_optimizations)
798799
: ProgramOptionReader<std::string>(vm, "pool"),
@@ -802,6 +803,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
802803
allow_pool_balancer(allow_pool_balancer),
803804
allow_pool_deep_scrubbing(allow_pool_deep_scrubbing),
804805
allow_pool_scrubbing(allow_pool_scrubbing),
806+
check_consistency(check_consistency),
805807
test_recovery(test_recovery),
806808
allow_pool_ec_optimizations(allow_pool_ec_optimizations),
807809
first_use(true),
@@ -831,7 +833,8 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
831833
bufferlist inbl, outbl;
832834
auto formatter = std::make_shared<JSONFormatter>(false);
833835

834-
ceph::messaging::osd::OSDPoolGetRequest osdPoolGetRequest{*force_value};
836+
ceph::messaging::osd::OSDPoolGetRequest osdPoolGetRequest{*force_value,
837+
"all"};
835838
rc = send_mon_command(osdPoolGetRequest, rados, "OSDPoolGetRequest", inbl,
836839
&outbl, formatter.get());
837840
ceph_assert(rc == 0);
@@ -843,18 +846,32 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
843846
ceph::messaging::osd::OSDPoolGetReply pool_get_reply;
844847
pool_get_reply.decode_json(&p);
845848

846-
profile = sep.selectExistingProfile(pool_get_reply.erasure_code_profile);
849+
if (pool_get_reply.erasure_code_profile.has_value()) {
850+
pool_type = pg_pool_t::TYPE_ERASURE;
851+
profile = sep.selectExistingProfile(*pool_get_reply.erasure_code_profile);
852+
} else {
853+
pool_type = pg_pool_t::TYPE_REPLICATED;
854+
if (check_consistency) {
855+
throw std::invalid_argument(fmt::format("checkconsistency option not "
856+
"allowed if using a {} pool",
857+
pg_pool_t::get_type_name(pool_type)));
858+
}
859+
}
847860
} else {
861+
pool_type = pg_pool_t::TYPE_ERASURE;
848862
created_pool_name = create();
849863
}
850864

851865
if (!dry_run) {
852-
configureServices(force_value.value_or(created_pool_name),
866+
configureServices(force_value.value_or(created_pool_name), pool_type,
853867
allow_pool_autoscaling, allow_pool_balancer,
854868
allow_pool_deep_scrubbing, allow_pool_scrubbing,
855869
allow_pool_ec_optimizations, true, test_recovery);
856870

857-
setApplication(created_pool_name);
871+
if (!force_value)
872+
{
873+
setApplication(created_pool_name);
874+
}
858875
}
859876
}
860877

@@ -897,6 +914,7 @@ void ceph::io_sequence::tester::SelectErasurePool::setApplication(
897914

898915
void ceph::io_sequence::tester::SelectErasurePool::configureServices(
899916
const std::string& pool_name,
917+
PoolType pool_type,
900918
bool allow_pool_autoscaling,
901919
bool allow_pool_balancer,
902920
bool allow_pool_deep_scrubbing,
@@ -952,26 +970,29 @@ void ceph::io_sequence::tester::SelectErasurePool::configureServices(
952970
ceph_assert(rc == 0);
953971
}
954972

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-
}
973+
if (pool_type == pg_pool_t::TYPE_ERASURE)
974+
{
975+
if (allow_pool_ec_optimizations) {
976+
ceph::messaging::osd::OSDPoolSetRequest
977+
allow_ec_optimisations_request{pool_name,
978+
"allow_ec_optimizations",
979+
"true",
980+
std::nullopt};
981+
rc = send_mon_command(allow_ec_optimisations_request, rados,
982+
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
983+
ceph_assert(rc == 0);
984+
}
965985

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);
986+
if (allow_pool_ec_overwrites) {
987+
ceph::messaging::osd::OSDPoolSetRequest
988+
allow_ec_optimisations_request{pool_name,
989+
"allow_ec_overwrites",
990+
"true",
991+
std::nullopt};
992+
rc = send_mon_command(allow_ec_optimisations_request, rados,
993+
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
994+
ceph_assert(rc == 0);
995+
}
975996
}
976997

977998
if (test_recovery) {
@@ -1004,11 +1025,13 @@ ceph::io_sequence::tester::TestObject::TestObject(
10041025
} else {
10051026
const std::string pool = spo.select();
10061027
if (!dryrun) {
1007-
ceph_assert(spo.getProfile());
1008-
pool_km = spo.getProfile()->km;
1009-
if (spo.getProfile()->mapping && spo.getProfile()->layers) {
1010-
pool_mappinglayers = {*spo.getProfile()->mapping,
1011-
*spo.getProfile()->layers};
1028+
if (!spo.is_replicated_pool()) {
1029+
ceph_assert(spo.getProfile());
1030+
pool_km = spo.getProfile()->km;
1031+
if (spo.getProfile()->mapping && spo.getProfile()->layers) {
1032+
pool_mappinglayers = {*spo.getProfile()->mapping,
1033+
*spo.getProfile()->layers};
1034+
}
10121035
}
10131036
}
10141037

@@ -1038,7 +1061,8 @@ ceph::io_sequence::tester::TestObject::TestObject(
10381061

10391062
exerciser_model = std::make_unique<ceph::io_exerciser::RadosIo>(
10401063
rados, asio, pool, oid, cached_shard_order, sbs.select(), rng(),
1041-
threads, lock, cond, spo.get_allow_pool_ec_optimizations());
1064+
threads, lock, cond, spo.is_replicated_pool(),
1065+
spo.get_allow_pool_ec_optimizations());
10421066
dout(0) << "= " << oid << " pool=" << pool << " threads=" << threads
10431067
<< " blocksize=" << exerciser_model->get_block_size() << " ="
10441068
<< dendl;
@@ -1130,6 +1154,7 @@ ceph::io_sequence::tester::TestRunner::TestRunner(
11301154
vm.contains("allow_pool_balancer"),
11311155
vm.contains("allow_pool_deep_scrubbing"),
11321156
vm.contains("allow_pool_scrubbing"),
1157+
vm.contains("checkconsistency"),
11331158
vm.contains("testrecovery"),
11341159
!vm.contains("disable_pool_ec_optimizations")},
11351160
snt{rng, vm, "threads", true},
@@ -1317,7 +1342,7 @@ bool ceph::io_sequence::tester::TestRunner::run_interactive_test() {
13171342
model = std::make_unique<ceph::io_exerciser::RadosIo>(
13181343
rados, asio, pool, object_name, osd_map_reply.acting, sbs.select(), rng(),
13191344
1, // 1 thread
1320-
lock, cond,
1345+
lock, cond, spo.is_replicated_pool(),
13211346
spo.get_allow_pool_ec_optimizations());
13221347
}
13231348

@@ -1473,6 +1498,10 @@ bool ceph::io_sequence::tester::TestRunner::run_automated_test() {
14731498
std::cerr << "Error: " << e.what() << std::endl;
14741499
return false;
14751500
}
1501+
catch (const std::invalid_argument &e) {
1502+
std::cerr << "Error: " << e.what() << std::endl;
1503+
return false;
1504+
}
14761505
}
14771506
if (!dryrun) {
14781507
rados.wait_for_latest_osdmap();

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
388388
bool allow_pool_balancer,
389389
bool allow_pool_deep_scrubbing,
390390
bool allow_pool_scrubbing,
391+
bool check_consistency,
391392
bool test_recovery,
392393
bool allow_pool_ec_optimizations);
393394
const std::string select() override;
@@ -402,6 +403,9 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
402403
inline bool get_allow_pool_ec_optimizations() {
403404
return allow_pool_ec_optimizations;
404405
}
406+
407+
inline bool is_replicated_pool() const { return pool_type
408+
== pg_pool_t::TYPE_REPLICATED; }
405409
inline std::optional<Profile> getProfile() { return profile; }
406410

407411
private:
@@ -412,16 +416,21 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
412416
bool allow_pool_balancer;
413417
bool allow_pool_deep_scrubbing;
414418
bool allow_pool_scrubbing;
419+
bool check_consistency;
415420
bool test_recovery;
416421
bool allow_pool_ec_optimizations;
417422

423+
using PoolType = int;
424+
PoolType pool_type;
425+
418426
bool first_use;
419427

420428
SelectErasureProfile sep;
421429

422430
std::optional<Profile> profile;
423431

424432
void configureServices(const std::string& pool_name,
433+
PoolType pool_type,
425434
bool allow_pool_autoscaling,
426435
bool allow_pool_balancer,
427436
bool allow_pool_deep_scrubbing,

0 commit comments

Comments
 (0)