Skip to content

Commit e8ef0f4

Browse files
committed
common: Added values to json::OSDPoolGetReply
OSDPoolGetReply actually returns a lot more values than what is currently supplied. These have been added in as optionals (as they can not be give as well) so its possible to query them to find out if they exist and use them if they do. Signed-off-by: Jon Bailey <[email protected]>
1 parent fbc054b commit e8ef0f4

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,8 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
831831
bufferlist inbl, outbl;
832832
auto formatter = std::make_shared<JSONFormatter>(false);
833833

834-
ceph::messaging::osd::OSDPoolGetRequest osdPoolGetRequest{*force_value};
834+
ceph::messaging::osd::OSDPoolGetRequest osdPoolGetRequest{*force_value,
835+
"all"};
835836
rc = send_mon_command(osdPoolGetRequest, rados, "OSDPoolGetRequest", inbl,
836837
&outbl, formatter.get());
837838
ceph_assert(rc == 0);

0 commit comments

Comments
 (0)