From 94ad124f868d384ab31a4533ecd3d1c39ca1aa89 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 13 Sep 2022 17:22:03 +0000 Subject: [PATCH] crimson/osd: bring the dump_recovery_reservations asok cmd Signed-off-by: Radoslaw Zarzynski --- src/crimson/admin/osd_admin.cc | 32 ++++++++++++++++++++++++++++++++ src/crimson/admin/osd_admin.h | 1 + src/crimson/osd/osd.cc | 2 ++ src/crimson/osd/shard_services.h | 6 ++++++ 4 files changed, 41 insertions(+) diff --git a/src/crimson/admin/osd_admin.cc b/src/crimson/admin/osd_admin.cc index 8214b8fd7ee..d93e294d28d 100644 --- a/src/crimson/admin/osd_admin.cc +++ b/src/crimson/admin/osd_admin.cc @@ -529,4 +529,36 @@ private: template std::unique_ptr make_asok_hook(const crimson::osd::OSDOperationRegistry& op_registry); +class DumpRecoveryReservationsHook : public AdminSocketHook { +public: + explicit DumpRecoveryReservationsHook(crimson::osd::ShardServices& shard_services) : + AdminSocketHook{"dump_recovery_reservations", "", "show recovery reservations"}, + shard_services(shard_services) + {} + seastar::future call(const cmdmap_t&, + std::string_view format, + ceph::bufferlist&& input) const final + { + logger().debug("{}", __func__); + unique_ptr f{Formatter::create(format, "json-pretty", "json-pretty")}; + return seastar::do_with(std::move(f), [this](auto&& f) { + f->open_object_section("reservations"); + f->open_object_section("local_reservations"); + return shard_services.local_dump_reservations(f.get()).then([&f, this] { + f->close_section(); + f->open_object_section("remote_reservations"); + return shard_services.remote_dump_reservations(f.get()).then([&f] { + f->close_section(); + f->close_section(); + return seastar::make_ready_future(std::move(f)); + }); + }); + }); + } +private: + crimson::osd::ShardServices& shard_services; +}; +template std::unique_ptr +make_asok_hook(crimson::osd::ShardServices& shard_services); + } // namespace crimson::admin diff --git a/src/crimson/admin/osd_admin.h b/src/crimson/admin/osd_admin.h index b3e0adc2a91..a3ddd66b9a6 100644 --- a/src/crimson/admin/osd_admin.h +++ b/src/crimson/admin/osd_admin.h @@ -20,6 +20,7 @@ class SendBeaconHook; class DumpInFlightOpsHook; class DumpHistoricOpsHook; class DumpSlowestHistoricOpsHook; +class DumpRecoveryReservationsHook; template std::unique_ptr make_asok_hook(Args&&... args); diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 56f23d356f5..e2554907a6e 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -615,6 +615,8 @@ seastar::future<> OSD::start_asok_admin() asok->register_command( make_asok_hook( std::as_const(get_shard_services().get_registry()))); + asok->register_command( + make_asok_hook(get_shard_services())); }); } diff --git a/src/crimson/osd/shard_services.h b/src/crimson/osd/shard_services.h index c853dd59d9d..1a3b9dc30a9 100644 --- a/src/crimson/osd/shard_services.h +++ b/src/crimson/osd/shard_services.h @@ -468,9 +468,15 @@ public: FORWARD_TO_OSD_SINGLETON_TARGET( local_cancel_reservation, local_reserver.cancel_reservation) + FORWARD_TO_OSD_SINGLETON_TARGET( + local_dump_reservations, + local_reserver.dump) FORWARD_TO_OSD_SINGLETON_TARGET( remote_cancel_reservation, remote_reserver.cancel_reservation) + FORWARD_TO_OSD_SINGLETON_TARGET( + remote_dump_reservations, + remote_reserver.dump) Context *invoke_context_on_core(core_id_t core, Context *c) { if (!c) return nullptr; -- 2.47.3