]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: bring the dump_recovery_reservations asok cmd 48073/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 13 Sep 2022 17:22:03 +0000 (17:22 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 7 Oct 2022 14:42:39 +0000 (14:42 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/admin/osd_admin.cc
src/crimson/admin/osd_admin.h
src/crimson/osd/osd.cc
src/crimson/osd/shard_services.h

index 8214b8fd7ee47bbb6eba0814784fac06f3959070..d93e294d28dd2b5293959939b516c557fcc19ab6 100644 (file)
@@ -529,4 +529,36 @@ private:
 template std::unique_ptr<AdminSocketHook>
 make_asok_hook<DumpSlowestHistoricOpsHook>(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<tell_result_t> call(const cmdmap_t&,
+                                     std::string_view format,
+                                     ceph::bufferlist&& input) const final
+  {
+    logger().debug("{}", __func__);
+    unique_ptr<Formatter> 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<tell_result_t>(std::move(f));
+        });
+      });
+    });
+  }
+private:
+  crimson::osd::ShardServices& shard_services;
+};
+template std::unique_ptr<AdminSocketHook>
+make_asok_hook<DumpRecoveryReservationsHook>(crimson::osd::ShardServices& shard_services);
+
 } // namespace crimson::admin
index b3e0adc2a91cf5eb7f8da3a60f304249c7622092..a3ddd66b9a6aefd6a652703116a9578db2b1e316 100644 (file)
@@ -20,6 +20,7 @@ class SendBeaconHook;
 class DumpInFlightOpsHook;
 class DumpHistoricOpsHook;
 class DumpSlowestHistoricOpsHook;
+class DumpRecoveryReservationsHook;
 
 template<class Hook, class... Args>
 std::unique_ptr<AdminSocketHook> make_asok_hook(Args&&... args);
index 56f23d356f516adf3342d0788021c5f61a5ed97f..e2554907a6e4526b123fee07689a078282525204 100644 (file)
@@ -615,6 +615,8 @@ seastar::future<> OSD::start_asok_admin()
     asok->register_command(
       make_asok_hook<DumpSlowestHistoricOpsHook>(
        std::as_const(get_shard_services().get_registry())));
+    asok->register_command(
+      make_asok_hook<DumpRecoveryReservationsHook>(get_shard_services()));
   });
 }
 
index c853dd59d9d7cba795d5621736bcd9f1e520baf3..1a3b9dc30a962343e55472be33bf5f7784eae61a 100644 (file)
@@ -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;