]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: reimplement get_mapped_pools
authorSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 13:35:15 +0000 (08:35 -0500)
committerSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 15:26:28 +0000 (10:26 -0500)
Output as a proper array this time.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 7f503ac56931bafe83958a9e1e7b81a9df5239af..14b349189da5f211e3165840c51edad9ba8d1f21 100644 (file)
@@ -2006,6 +2006,17 @@ public:
   }
 };
 
+std::set<int64_t> OSD::get_mapped_pools()
+{
+  std::set<int64_t> pools;
+  std::vector<spg_t> 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<int64_t> 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;
index 721fa5d59101a9abbc58fa84e09bd9cd5e70ccd5..f7f322f66d9b983c84e15746845f190ec0011c71 100644 (file)
@@ -1859,6 +1859,8 @@ protected:
 public:
   PGRef lookup_lock_pg(spg_t pgid);
 
+  std::set<int64_t> get_mapped_pools();
+
 protected:
   PG* _make_pg(OSDMapRef createmap, spg_t pgid);