]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Added values to json::OSDPoolGetReply
authorJon Bailey <jonathan.bailey1@ibm.com>
Mon, 14 Jul 2025 12:52:28 +0000 (13:52 +0100)
committerJon Bailey <jonathan.bailey1@ibm.com>
Sun, 7 Sep 2025 09:27:36 +0000 (10:27 +0100)
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 <jonathan.bailey1@ibm.com>
src/common/json/OSDStructures.cc
src/common/json/OSDStructures.h
src/erasure-code/consistency/RadosCommands.cc
src/erasure-code/consistency/ceph_ec_consistency_checker.cc
src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc

index f374b05360d4db43d534dcc1d9092fe05f77ba03..24e3e0ce60e24f8a45291fdf2292d151a0de7f57 100644 (file)
@@ -60,12 +60,36 @@ void OSDPoolGetRequest::decode_json(JSONObj* obj) {
 }
 
 void OSDPoolGetReply::dump(Formatter* f) const {
+  encode_json("size", size, f);
+  encode_json("min_size", min_size, f);
+  encode_json("pg_num", pg_num, f);
+  encode_json("pgp_num", pgp_num, f);
+  encode_json("crush_rule", crush_rule, f);
+  encode_json("allow_ec_overwrites", allow_ec_overwrites, f);
+  encode_json("nodelete", nodelete, f);
+  encode_json("nopgchange", nopgchange, f);
+  encode_json("nosizechange", nosizechange, f);
+  encode_json("noscrub", noscrub, f);
+  encode_json("nodeep-scrub", nodeep_scrub, f);
   encode_json("erasure_code_profile", erasure_code_profile, f);
+  encode_json("fast_read", fast_read, f);
   encode_json("allow_ec_optimizations", allow_ec_optimizations, f);
 }
 
 void OSDPoolGetReply::decode_json(JSONObj* obj) {
+  JSONDecoder::decode_json("size", size, obj);
+  JSONDecoder::decode_json("min_size", min_size, obj);
+  JSONDecoder::decode_json("pg_num", pg_num, obj);
+  JSONDecoder::decode_json("pgp_num", pgp_num, obj);
+  JSONDecoder::decode_json("crush_rule", crush_rule, obj);
+  JSONDecoder::decode_json("allow_ec_overwrites", allow_ec_overwrites, obj);
+  JSONDecoder::decode_json("nodelete", nodelete, obj);
+  JSONDecoder::decode_json("nopgchange", nopgchange, obj);
+  JSONDecoder::decode_json("nosizechange", nosizechange, obj);
+  JSONDecoder::decode_json("noscrub", noscrub, obj);
+  JSONDecoder::decode_json("nodeep-scrub", nodeep_scrub, obj);
   JSONDecoder::decode_json("erasure_code_profile", erasure_code_profile, obj);
+  JSONDecoder::decode_json("fast_read", fast_read, obj);
   JSONDecoder::decode_json("allow_ec_optimizations", allow_ec_optimizations, obj);
 }
 
index d4f97bd9b958fe8b6b763765f723fa9047773ceb..9f6d1c7e824653c4fd0957f1e5f0216cbc06e36b 100644 (file)
@@ -41,7 +41,7 @@ struct OSDMapReply {
 
 struct OSDPoolGetRequest {
   std::string pool;
-  std::string var = "erasure_code_profile";
+  std::string var;
   std::string format = "json";
 
   void dump(Formatter* f) const;
@@ -49,8 +49,21 @@ struct OSDPoolGetRequest {
 };
 
 struct OSDPoolGetReply {
-  std::string erasure_code_profile;
-  bool allow_ec_optimizations;
+  std::optional<int> size;
+  std::optional<int> min_size;
+  std::optional<int> pg_num;
+  std::optional<int> pgp_num;
+  std::optional<std::string> crush_rule;
+  std::optional<bool> allow_ec_overwrites;
+  std::optional<bool> nodelete;
+  std::optional<bool> nopgchange;
+  std::optional<bool> nosizechange;
+  std::optional<bool> noscrub;
+  std::optional<bool> nodeep_scrub;
+  std::optional<std::string> erasure_code_profile;
+  std::optional<int> fast_read;
+  std::optional<bool> allow_ec_optimizations;
+
   void dump(Formatter* f) const;
   void decode_json(JSONObj* obj);
 };
index 8fb97587f1f8a77e9c342c81623d248ed702c768..0eaab5db75c52138d927ed7f7170da3322296692 100644 (file)
@@ -54,7 +54,7 @@ int RadosCommands::get_primary_osd(const std::string& pool_name,
  */
 bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name)
 {
-  ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name, "allow_ec_optimizations"};
+  ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name, "all"};
   encode_json("OSDPoolGetRequest", osd_pool_get_request, formatter.get());
 
   std::ostringstream oss;
@@ -71,7 +71,7 @@ bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name
   ceph::messaging::osd::OSDPoolGetReply osd_pool_get_reply;
   osd_pool_get_reply.decode_json(&p);
 
-  return osd_pool_get_reply.allow_ec_optimizations;
+  return osd_pool_get_reply.allow_ec_optimizations.value_or(false);
 }
 
 /**
@@ -83,7 +83,7 @@ bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name
  */
 std::string RadosCommands::get_pool_ec_profile_name(const std::string& pool_name)
 {
-  ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name};
+  ceph::messaging::osd::OSDPoolGetRequest osd_pool_get_request{pool_name, "all"};
   encode_json("OSDPoolGetRequest", osd_pool_get_request, formatter.get());
 
   std::ostringstream oss;
@@ -100,7 +100,12 @@ std::string RadosCommands::get_pool_ec_profile_name(const std::string& pool_name
   ceph::messaging::osd::OSDPoolGetReply osd_pool_get_reply;
   osd_pool_get_reply.decode_json(&p);
 
-  return osd_pool_get_reply.erasure_code_profile;
+  if (!osd_pool_get_reply.erasure_code_profile) {
+    throw std::runtime_error("No profile for given pool. "
+                             "Is it an Erasure Coded pool?");
+  }
+
+  return *osd_pool_get_reply.erasure_code_profile;
 }
 
 /**
index 35606084b2ae4b24c93c4d33eb9671cbd6300f4d..4a783724c7d21618c1a10db7a779bdbed4e280cd 100644 (file)
@@ -71,9 +71,14 @@ int main(int argc, char **argv)
   guard.emplace(boost::asio::make_work_guard(asio));
   thread = make_named_thread("io_thread",[&asio] { asio.run(); });
 
-  auto checker = ceph::consistency::ConsistencyChecker(rados, asio, pool);
-  checker.single_read_and_check_consistency(oid, blocksize, offset, length);
-  checker.print_results(std::cout);
+  try {
+    auto checker = ceph::consistency::ConsistencyChecker(rados, asio, pool);
+    checker.single_read_and_check_consistency(oid, blocksize, offset, length);
+    checker.print_results(std::cout);
+  } catch (std::runtime_error& e) {
+    std::cerr << e.what() << std::endl;
+    exit(1);
+  }
 
   exit(0);
 }
\ No newline at end of file
index 980e8d9f26fd995c5919d0e6033cd332cc9ff924..0526527be0ab0a269693841ab5a97aebcefa5bde 100644 (file)
@@ -831,7 +831,8 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
       bufferlist inbl, outbl;
       auto formatter = std::make_shared<JSONFormatter>(false);
 
-      ceph::messaging::osd::OSDPoolGetRequest osdPoolGetRequest{*force_value};
+      ceph::messaging::osd::OSDPoolGetRequest osdPoolGetRequest{*force_value,
+                                                                "all"};
       rc = send_mon_command(osdPoolGetRequest, rados, "OSDPoolGetRequest", inbl,
                             &outbl, formatter.get());
       ceph_assert(rc == 0);