Skip to content

Commit a4d93bb

Browse files
author
Connor Fawcett
committed
Get chunk size for consistency checking from EC profile instead of command line arg
Signed-off-by: Connor Fawcett <[email protected]>
1 parent 98d8c60 commit a4d93bb

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

src/erasure-code/consistency/ConsistencyChecker.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ using bufferlist = ceph::bufferlist;
1414

1515
ConsistencyChecker::ConsistencyChecker(librados::Rados &rados,
1616
boost::asio::io_context& asio,
17-
const std::string& pool_name,
18-
int stripe_unit) :
17+
const std::string& pool_name) :
1918
rados(rados),
2019
asio(asio),
2120
reader(ceph::consistency::ECReader(rados, asio, pool_name)),
@@ -24,7 +23,7 @@ ConsistencyChecker::ConsistencyChecker(librados::Rados &rados,
2423
commands.get_ec_profile_for_pool(pool_name),
2524
commands.get_pool_allow_ec_optimizations(pool_name)),
2625
encoder(ceph::consistency::ECEncoderSwitch(pool.get_ec_profile(),
27-
stripe_unit,
26+
commands.get_ec_chunk_size_for_pool(pool_name),
2827
commands.get_pool_allow_ec_optimizations(pool_name)
2928
)) {}
3029

src/erasure-code/consistency/ConsistencyChecker.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class ConsistencyChecker {
5252
public:
5353
ConsistencyChecker(librados::Rados& rados,
5454
boost::asio::io_context& asio,
55-
const std::string& pool_name,
56-
int stripe_unit);
55+
const std::string& pool_name);
5756
void queue_ec_read(Read read);
5857
bool check_object_consistency(const std::string& oid,
5958
const bufferlist& inbl);

src/erasure-code/consistency/RadosCommands.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,19 @@ ceph::ErasureCodeProfile RadosCommands::get_ec_profile_for_pool(const std::strin
137137
}
138138

139139
/**
140-
* RadosCommands the parity read inject on the acting primary
140+
* Get chunk size for pool with the supplied name
141+
*
142+
* @param pool_name string Name of the pool to get chunk size of
143+
* @return int the chunk size of the pool
144+
*/
145+
int RadosCommands::get_ec_chunk_size_for_pool(const std::string& pool_name)
146+
{
147+
ceph::ErasureCodeProfile profile = get_ec_profile_for_pool(pool_name);
148+
return (profile.contains("stripe_unit") ? std::stol(profile["stripe_unit"]) : 4096);
149+
}
150+
151+
/**
152+
* Inject the parity read inject on the acting primary
141153
* for the specified object and pool. Assert on failure.
142154
*
143155
* @param pool_name string Name of the pool to perform inject on

src/erasure-code/consistency/RadosCommands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class RadosCommands {
2424
std::string get_pool_ec_profile_name(const std::string& pool_name);
2525
bool get_pool_allow_ec_optimizations(const std::string& pool_name);
2626
ceph::ErasureCodeProfile get_ec_profile_for_pool(const std::string& pool_name);
27+
int get_ec_chunk_size_for_pool(const std::string& pool_name);
2728
void inject_parity_read_on_primary_osd(const std::string& pool_name,
2829
const std::string& oid);
2930
void inject_clear_parity_read_on_primary_osd(const std::string& pool_name,

src/erasure-code/consistency/ceph_ec_consistency_checker.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ int main(int argc, char **argv)
3535
("oid,i", po::value<std::string>(), "object io")
3636
("blocksize,b", po::value<int>(), "block size")
3737
("offset,o", po::value<int>(), "offset")
38-
("length,l", po::value<int>(), "length")
39-
("stripeunit,s", po::value<int>(), "stripe unit");
38+
("length,l", po::value<int>(), "length");
4039

4140
po::variables_map vm;
4241
std::vector<std::string> unrecognized_options;
@@ -62,7 +61,6 @@ int main(int argc, char **argv)
6261
auto blocksize = vm["blocksize"].as<int>();
6362
auto offset = vm["offset"].as<int>();
6463
auto length = vm["length"].as<int>();
65-
auto stripe_unit = vm["stripeunit"].as<int>();
6664

6765
int rc;
6866
rc = rados.init_with_context(g_ceph_context);
@@ -73,7 +71,7 @@ int main(int argc, char **argv)
7371
guard.emplace(boost::asio::make_work_guard(asio));
7472
thread = make_named_thread("io_thread",[&asio] { asio.run(); });
7573

76-
auto checker = ceph::consistency::ConsistencyChecker(rados, asio, pool, stripe_unit);
74+
auto checker = ceph::consistency::ConsistencyChecker(rados, asio, pool);
7775
checker.single_read_and_check_consistency(oid, blocksize, offset, length);
7876
checker.print_results(std::cout);
7977

0 commit comments

Comments
 (0)