From: Ronen Friedman Date: Thu, 16 Apr 2026 17:58:09 +0000 (+0000) Subject: crimson/tools/objectstore: add GC operation to crimson-objectstore-tool X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c938fb306ceaa2c340eea1de3bbd14b97ddb1d7f;p=ceph.git crimson/tools/objectstore: add GC operation to crimson-objectstore-tool This adds a GC operation to the crimson-objectstore-tool, allowing us to trigger GC cycles on demand during testing. This will help reduce segment pressure and avoid 'no-segments' conditions. Signed-off-by: Ronen Friedman --- diff --git a/src/crimson/os/seastore/extent_placement_manager.h b/src/crimson/os/seastore/extent_placement_manager.h index af823f8c2091..123826f16be7 100644 --- a/src/crimson/os/seastore/extent_placement_manager.h +++ b/src/crimson/os/seastore/extent_placement_manager.h @@ -882,6 +882,7 @@ private: } seastar::future<> run_until_halt(); + seastar::future<> run_cleaner_until_done(); bool is_no_background() const { diff --git a/src/crimson/tools/objectstore/crimson_objectstore_tool.cc b/src/crimson/tools/objectstore/crimson_objectstore_tool.cc index 4c37abc3000b..f3c39e35e452 100644 --- a/src/crimson/tools/objectstore/crimson_objectstore_tool.cc +++ b/src/crimson/tools/objectstore/crimson_objectstore_tool.cc @@ -92,6 +92,9 @@ enum class operation_type_t { // Device-inspection operations (--op) DUMP_SUPERBLOCK, + + // Maintenance operations (--op) + GC, }; std::string to_string(operation_type_t op) { @@ -115,6 +118,7 @@ std::string to_string(operation_type_t op) { case operation_type_t::SET_SIZE: return "set-size"; case operation_type_t::CLEAR_DATA_DIGEST: return "clear-data-digest"; case operation_type_t::DUMP_SUPERBLOCK: return "dump-superblock"; + case operation_type_t::GC: return "gc"; default: return "unknown"; } } @@ -124,6 +128,7 @@ tl::expected parse_pg_operation(const std::string if (op_str == "list") return operation_type_t::LIST_OBJECTS; if (op_str == "info") return operation_type_t::INFO; if (op_str == "dump-superblock") return operation_type_t::DUMP_SUPERBLOCK; + if (op_str == "gc") return operation_type_t::GC; return tl::unexpected("Unsupported PG operation: " + op_str); } @@ -723,7 +728,8 @@ seastar::future run_tool(StoreTool& st, objectstore_config_t& config) { // Resolve object and pgid before executing operations if (config.operation->op != operation_type_t::LIST_PGS && - config.operation->op != operation_type_t::DUMP_SUPERBLOCK) { + config.operation->op != operation_type_t::DUMP_SUPERBLOCK && + config.operation->op != operation_type_t::GC) { bool resolved = co_await resolve_operation_parameters(st, config); if (!resolved) { co_return EXIT_FAILURE; @@ -996,6 +1002,11 @@ seastar::future run_tool(StoreTool& st, objectstore_config_t& config) { break; } + case operation_type_t::GC: { + co_await st.do_gc(); + break; + } + default: fmt::println(std::cerr, "Operation {} not implemented yet", to_string(op.op)); co_return EXIT_FAILURE; diff --git a/src/crimson/tools/objectstore/objectstore_tool.cc b/src/crimson/tools/objectstore/objectstore_tool.cc index 6fd8d6027482..c861dd20822b 100644 --- a/src/crimson/tools/objectstore/objectstore_tool.cc +++ b/src/crimson/tools/objectstore/objectstore_tool.cc @@ -26,6 +26,11 @@ seastar::future<> StoreTool::stop() co_return; } +seastar::future<> StoreTool::do_gc() +{ + co_await store->do_gc(); +} + seastar::future> StoreTool::list_pgs() { co_return co_await store->list_collections(); diff --git a/src/crimson/tools/objectstore/objectstore_tool.h b/src/crimson/tools/objectstore/objectstore_tool.h index f8000d5092a9..ce5470c98208 100644 --- a/src/crimson/tools/objectstore/objectstore_tool.h +++ b/src/crimson/tools/objectstore/objectstore_tool.h @@ -25,6 +25,7 @@ public: StoreTool(std::unique_ptr store): store(std::move(store)) {} seastar::future<> stop(); + seastar::future<> do_gc(); void set_shard_id(seastar::shard_id shard_id) { this->shard_id = shard_id; } // PG operations