From: Jon Bailey Date: Thu, 17 Jul 2025 15:51:58 +0000 (+0100) Subject: test/osd: Move initialisation of overwrites and optimisation earlier in ceph_test_rad... X-Git-Tag: v21.0.0~50^2~181^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=30670d38dce2d37a94636078fe9bbf04ed3a260e;p=ceph.git test/osd: Move initialisation of overwrites and optimisation earlier in ceph_test_rados_io_sequence All other pool initialisation happens straight after pool creation, however these two items happen later on. This is just due to them being the first two rest calls added. We now have better and more logical places for this code and this commit is moving it into this structure. Signed-off-by: Jon Bailey --- diff --git a/src/common/io_exerciser/RadosIo.cc b/src/common/io_exerciser/RadosIo.cc index 8161af16fad3..985101170a38 100644 --- a/src/common/io_exerciser/RadosIo.cc +++ b/src/common/io_exerciser/RadosIo.cc @@ -63,10 +63,6 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio, int rc; rc = rados.ioctx_create(pool.c_str(), io); ceph_assert(rc == 0); - allow_ec_overwrites(true); - if (ec_optimizations) { - allow_ec_optimizations(); - } } RadosIo::~RadosIo() {} @@ -90,28 +86,6 @@ void RadosIo::wait_for_io(int count) { } } -void RadosIo::allow_ec_overwrites(bool allow) { - int rc; - bufferlist inbl, outbl; - std::string cmdstr = "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool + - "\", \ - \"var\": \"allow_ec_overwrites\", \"val\": \"" + - (allow ? "true" : "false") + "\"}"; - rc = rados.mon_command(cmdstr, inbl, &outbl, nullptr); - ceph_assert(rc == 0); -} - -void RadosIo::allow_ec_optimizations() -{ - int rc; - bufferlist inbl, outbl; - std::string cmdstr = - "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool + "\", \ - \"var\": \"allow_ec_optimizations\", \"val\": \"true\"}"; - rc = rados.mon_command(cmdstr, inbl, &outbl, nullptr); - ceph_assert(rc == 0); -} - template RadosIo::AsyncOpInfo::AsyncOpInfo(const std::array& offset, const std::array& length) @@ -197,8 +171,14 @@ void RadosIo::applyIoOp(IoOp& op) { case OpType::Consistency: { start_io(); + ceph_assert(cc); bool is_consistent = - cc->single_read_and_check_consistency(oid, block_size, 0, 0); + cc->single_read_and_check_consistency(oid, block_size, 0, 0); + if (!is_consistent) { + std::stringstream strstream; + cc->print_results(strstream); + std::cerr << strstream.str() << std::endl; + } ceph_assert(is_consistent); finish_io(); break; diff --git a/src/common/json/OSDStructures.cc b/src/common/json/OSDStructures.cc index 874c314f5dd1..f374b05360d4 100644 --- a/src/common/json/OSDStructures.cc +++ b/src/common/json/OSDStructures.cc @@ -69,6 +69,21 @@ void OSDPoolGetReply::decode_json(JSONObj* obj) { JSONDecoder::decode_json("allow_ec_optimizations", allow_ec_optimizations, obj); } +void OSDPoolSetRequest::dump(Formatter* f) const { + encode_json("prefix", "osd pool set", f); + encode_json("pool", pool, f); + encode_json("var", var, f); + encode_json("val", val, f); + encode_json("yes_i_really_mean_it", yes_i_really_mean_it, f); +} + +void OSDPoolSetRequest::decode_json(JSONObj* obj) { + JSONDecoder::decode_json("pool", pool, obj); + JSONDecoder::decode_json("var", var, obj); + JSONDecoder::decode_json("val", val, obj); + JSONDecoder::decode_json("yes_i_really_mean_it", yes_i_really_mean_it, obj); +} + void OSDECProfileGetRequest::dump(Formatter* f) const { encode_json("prefix", "osd erasure-code-profile get", f); encode_json("name", name, f); diff --git a/src/common/json/OSDStructures.h b/src/common/json/OSDStructures.h index ea94a2bd6414..d4f97bd9b958 100644 --- a/src/common/json/OSDStructures.h +++ b/src/common/json/OSDStructures.h @@ -55,6 +55,16 @@ struct OSDPoolGetReply { void decode_json(JSONObj* obj); }; +struct OSDPoolSetRequest { + std::string pool; + std::string var; + std::optional val; + std::optional yes_i_really_mean_it = std::nullopt; + + void dump(Formatter* f) const; + void decode_json(JSONObj* obj); +}; + struct OSDECProfileGetRequest { std::string name; std::string format = "json"; diff --git a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc index 5cfa84af70f7..980e8d9f26fd 100644 --- a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc +++ b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc @@ -794,7 +794,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool( bool allow_pool_deep_scrubbing, bool allow_pool_scrubbing, bool test_recovery, - bool disable_pool_ec_optimizations) + bool allow_pool_ec_optimizations) : ProgramOptionReader(vm, "pool"), rados(rados), dry_run(dry_run), @@ -803,7 +803,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool( allow_pool_deep_scrubbing(allow_pool_deep_scrubbing), allow_pool_scrubbing(allow_pool_scrubbing), test_recovery(test_recovery), - disable_pool_ec_optimizations(disable_pool_ec_optimizations), + allow_pool_ec_optimizations(allow_pool_ec_optimizations), first_use(true), sep{cct, rng, vm, rados, dry_run, first_use} { if (isForced()) { @@ -849,9 +849,10 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() { } if (!dry_run) { - configureServices(allow_pool_autoscaling, allow_pool_balancer, + configureServices(force_value.value_or(created_pool_name), + allow_pool_autoscaling, allow_pool_balancer, allow_pool_deep_scrubbing, allow_pool_scrubbing, - test_recovery); + allow_pool_ec_optimizations, true, test_recovery); setApplication(created_pool_name); } @@ -868,7 +869,7 @@ std::string ceph::io_sequence::tester::SelectErasurePool::create() { std::string pool_name; profile = sep.select(); pool_name = fmt::format("testpool-pr{}{}", profile->name, - disable_pool_ec_optimizations?"_no_ec_opt":""); + allow_pool_ec_optimizations?"":"_no_ec_opt"); ceph::messaging::osd::OSDECPoolCreateRequest pool_create_request{ pool_name, "erasure", 8, 8, profile->name}; @@ -895,10 +896,13 @@ void ceph::io_sequence::tester::SelectErasurePool::setApplication( } void ceph::io_sequence::tester::SelectErasurePool::configureServices( + const std::string& pool_name, bool allow_pool_autoscaling, bool allow_pool_balancer, bool allow_pool_deep_scrubbing, bool allow_pool_scrubbing, + bool allow_pool_ec_optimizations, + bool allow_pool_ec_overwrites, bool test_recovery) { int rc; bufferlist inbl, outbl; @@ -942,12 +946,34 @@ void ceph::io_sequence::tester::SelectErasurePool::configureServices( if (!allow_pool_scrubbing) { ceph::messaging::osd::OSDSetRequest no_scrub_request{"noscrub", - std::nullopt}; + std::nullopt}; rc = send_mon_command(no_scrub_request, rados, "OSDSetRequest", inbl, &outbl, formatter.get()); ceph_assert(rc == 0); } + if (allow_pool_ec_optimizations) { + ceph::messaging::osd::OSDPoolSetRequest + allow_ec_optimisations_request{pool_name, + "allow_ec_optimizations", + "true", + std::nullopt}; + rc = send_mon_command(allow_ec_optimisations_request, rados, + "OSDPoolSetRequest", inbl, &outbl, formatter.get()); + ceph_assert(rc == 0); + } + + if (allow_pool_ec_overwrites) { + ceph::messaging::osd::OSDPoolSetRequest + allow_ec_optimisations_request{pool_name, + "allow_ec_overwrites", + "true", + std::nullopt}; + rc = send_mon_command(allow_ec_optimisations_request, rados, + "OSDPoolSetRequest", inbl, &outbl, formatter.get()); + ceph_assert(rc == 0); + } + if (test_recovery) { ceph::messaging::config::ConfigSetRequest bluestore_debug_request{ "global", "bluestore_debug_inject_read_err", "true", std::nullopt}; @@ -1105,7 +1131,7 @@ ceph::io_sequence::tester::TestRunner::TestRunner( vm.contains("allow_pool_deep_scrubbing"), vm.contains("allow_pool_scrubbing"), vm.contains("testrecovery"), - vm.contains("disable_pool_ec_optimizations")}, + !vm.contains("disable_pool_ec_optimizations")}, snt{rng, vm, "threads", true}, ssr{vm} { dout(0) << "Test using seed " << seed << dendl; @@ -1127,7 +1153,6 @@ ceph::io_sequence::tester::TestRunner::TestRunner( allow_pool_balancer = vm.contains("allow_pool_balancer"); allow_pool_deep_scrubbing = vm.contains("allow_pool_deep_scrubbing"); allow_pool_scrubbing = vm.contains("allow_pool_scrubbing"); - disable_pool_ec_optimizations = vm.contains("disable_pool_ec_optimizations"); if (testrecovery && (num_objects > 1)) { throw std::invalid_argument("testrecovery option not allowed if parallel is" diff --git a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h index f5c46c19e0e8..d12e98416f72 100644 --- a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h +++ b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h @@ -389,7 +389,7 @@ class SelectErasurePool : public ProgramOptionReader { bool allow_pool_deep_scrubbing, bool allow_pool_scrubbing, bool test_recovery, - bool disable_pool_ec_optimizations); + bool allow_pool_ec_optimizations); const std::string select() override; std::string create(); @@ -400,7 +400,7 @@ class SelectErasurePool : public ProgramOptionReader { } inline bool get_allow_pool_scrubbing() { return allow_pool_scrubbing; } inline bool get_allow_pool_ec_optimizations() { - return !disable_pool_ec_optimizations; + return allow_pool_ec_optimizations; } inline std::optional getProfile() { return profile; } @@ -413,7 +413,7 @@ class SelectErasurePool : public ProgramOptionReader { bool allow_pool_deep_scrubbing; bool allow_pool_scrubbing; bool test_recovery; - bool disable_pool_ec_optimizations; + bool allow_pool_ec_optimizations; bool first_use; @@ -421,10 +421,13 @@ class SelectErasurePool : public ProgramOptionReader { std::optional profile; - void configureServices(bool allow_pool_autoscaling, + void configureServices(const std::string& pool_name, + bool allow_pool_autoscaling, bool allow_pool_balancer, bool allow_pool_deep_scrubbing, bool allow_pool_scrubbing, + bool disable_pool_ec_optimizations, + bool allow_pool_ec_overwrites, bool test_recovery); void setApplication(const std::string& pool_name); @@ -515,7 +518,6 @@ class TestRunner { bool allow_pool_balancer; bool allow_pool_deep_scrubbing; bool allow_pool_scrubbing; - bool disable_pool_ec_optimizations; bool show_sequence; bool show_help;