From: Radoslaw Zarzynski Date: Tue, 13 Sep 2022 17:22:03 +0000 (+0000) Subject: crimson/osd: bring the dump_recovery_reservations asok cmd X-Git-Tag: v18.1.0~1051^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F48073%2Fhead;p=ceph.git crimson/osd: bring the dump_recovery_reservations asok cmd Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/admin/osd_admin.cc b/src/crimson/admin/osd_admin.cc index 8214b8fd7ee4..d93e294d28dd 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 b3e0adc2a91c..a3ddd66b9a6a 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 56f23d356f51..e2554907a6e4 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 c853dd59d9d7..1a3b9dc30a96 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;