From: Sage Weil Date: Wed, 4 Apr 2018 13:35:15 +0000 (-0500) Subject: osd: reimplement get_mapped_pools X-Git-Tag: v13.1.0~390^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f4f8ce257d3cbf386d87239967c78e652de83e0;p=ceph.git osd: reimplement get_mapped_pools Output as a proper array this time. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 7f503ac56931..14b349189da5 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2006,6 +2006,17 @@ public: } }; +std::set OSD::get_mapped_pools() +{ + std::set pools; + std::vector pgids; + _get_pgids(&pgids); + for (const auto &pgid : pgids) { + pools.insert(pgid.pool()); + } + return pools; +} + bool OSD::asok_command(std::string_view admin_command, const cmdmap_t& cmdmap, std::string_view format, ostream& ss) { @@ -2212,6 +2223,13 @@ will start to track new ops received afterwards."; f->open_object_section("compact_result"); f->dump_float("elapsed_time", duration); f->close_section(); + } else if (admin_command == "get_mapped_pools") { + f->open_array_section("mapped_pools"); + set poollist = get_mapped_pools(); + for (auto pool : poollist) { + f->dump_int("pool_id", pool); + } + f->close_section(); } else if (admin_command == "smart") { probe_smart(ss); } else if (admin_command == "list_devices") { @@ -2777,6 +2795,12 @@ void OSD::final_init() " WARNING: Compaction probably slows your requests"); assert(r == 0); + r = admin_socket->register_command("get_mapped_pools", "get_mapped_pools", + asok_hook, + "dump pools whose PG(s) are mapped to this OSD."); + + assert(r == 0); + r = admin_socket->register_command("smart", "smart", asok_hook, "probe OSD devices for SMART data."); @@ -3271,6 +3295,7 @@ int OSD::shutdown() cct->get_admin_socket()->unregister_command("flush_store_cache"); cct->get_admin_socket()->unregister_command("dump_pgstate_history"); cct->get_admin_socket()->unregister_command("compact"); + cct->get_admin_socket()->unregister_command("get_mapped_pools"); cct->get_admin_socket()->unregister_command("smart"); cct->get_admin_socket()->unregister_command("list_devices"); delete asok_hook; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 721fa5d59101..f7f322f66d9b 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1859,6 +1859,8 @@ protected: public: PGRef lookup_lock_pg(spg_t pgid); + std::set get_mapped_pools(); + protected: PG* _make_pg(OSDMapRef createmap, spg_t pgid);