]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: change 'debug dump_missing'
authorSage Weil <sage@redhat.com>
Mon, 18 Sep 2017 18:59:33 +0000 (13:59 -0500)
committerSage Weil <sage@redhat.com>
Fri, 6 Oct 2017 18:08:18 +0000 (13:08 -0500)
- json
- move into PG class

No users in the qa suite.

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

index da4bc3a043a3b423318c2ef2f8156b9a2c304cd4..a3d4f99211051216cf5d9af6d3653888ebc84e3e 100644 (file)
@@ -6195,43 +6195,23 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe
   }
 
   else if (prefix == "debug dump_missing") {
-    string file_name;
-    cmd_getval(cct, cmdmap, "filename", file_name);
-    std::ofstream fout(file_name.c_str());
-    if (!fout.is_open()) {
-       ss << "failed to open file '" << file_name << "'";
-       r = -EINVAL;
-       goto out;
+    if (!f) {
+      f.reset(new JSONFormatter(true));
     }
-
-    fout << "*** osd " << whoami << ": dump_missing ***" << std::endl;
+    f->open_array_section("pgs");
     RWLock::RLocker l(pg_map_lock);
     for (ceph::unordered_map<spg_t, PG*>::const_iterator pg_map_e = pg_map.begin();
         pg_map_e != pg_map.end(); ++pg_map_e) {
       PG *pg = pg_map_e->second;
+      string s = stringify(pg->pg_id);
+      f->open_array_section(s.c_str());
       pg->lock();
-
-      fout << *pg << std::endl;
-      std::map<hobject_t, pg_missing_item>::const_iterator mend =
-       pg->pg_log.get_missing().get_items().end();
-      std::map<hobject_t, pg_missing_item>::const_iterator mi =
-       pg->pg_log.get_missing().get_items().begin();
-      for (; mi != mend; ++mi) {
-       fout << mi->first << " -> " << mi->second << std::endl;
-       if (!pg->missing_loc.needs_recovery(mi->first))
-         continue;
-       if (pg->missing_loc.is_unfound(mi->first))
-         fout << " unfound ";
-       const set<pg_shard_t> &mls(pg->missing_loc.get_locations(mi->first));
-       if (mls.empty())
-         continue;
-       fout << "missing_loc: " << mls << std::endl;
-      }
+      pg->dump_missing(f.get());
       pg->unlock();
-      fout << std::endl;
+      f->close_section();
     }
-
-    fout.close();
+    f->close_section();
+    f->flush(ss);
   }
   else if (prefix == "debug kick_recovery_wq") {
     int64_t delay;
index 13b954c3f92c7e8f9374d08df31cdad36e8e70e5..00f29614986e43d2b18ae69e0a37d2e437760f7f 100644 (file)
@@ -8258,6 +8258,24 @@ void PG::dump_pgstate_history(Formatter *f)
   unlock();
 }
 
+void PG::dump_missing(Formatter *f)
+{
+  for (auto& i : pg_log.get_missing().get_items()) {
+    f->open_object_section("object");
+    f->dump_object("oid", i.first);
+    f->dump_object("missing_info", i.second);
+    if (missing_loc.needs_recovery(i.first)) {
+      f->dump_bool("unfound", missing_loc.is_unfound(i.first));
+      f->open_array_section("locations");
+      for (auto l : missing_loc.get_locations(i.first)) {
+       f->dump_object("shard", l);
+      }
+      f->close_section();
+    }
+    f->close_section();
+  }
+}
+
 void PG::get_pg_stats(std::function<void(const pg_stat_t&, epoch_t lec)> f)
 {
   pg_stats_publish_lock.Lock();
index 3cf56c9d18d7b58b35c4627f25ed79ad9168c7ac..fb69a6280a4caa1613d21b68875ae2a149afacfb 100644 (file)
@@ -456,6 +456,7 @@ public:
   virtual void get_watchers(std::list<obj_watch_item_t> *ls) = 0;
 
   void dump_pgstate_history(Formatter *f);
+  void dump_missing(Formatter *f);
 
   void get_pg_stats(std::function<void(const pg_stat_t&, epoch_t lec)> f);
   void with_heartbeat_peers(std::function<void(int)> f);