From: Sage Weil Date: Mon, 18 Sep 2017 18:59:33 +0000 (-0500) Subject: osd/PG: change 'debug dump_missing' X-Git-Tag: v13.0.1~634^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a3a3fdae719b8ac6acde649d0142275fc079a09;p=ceph-ci.git osd/PG: change 'debug dump_missing' - json - move into PG class No users in the qa suite. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index da4bc3a043a..a3d4f992110 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6195,43 +6195,23 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& 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::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::const_iterator mend = - pg->pg_log.get_missing().get_items().end(); - std::map::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 &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; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 13b954c3f92..00f29614986 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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 f) { pg_stats_publish_lock.Lock(); diff --git a/src/osd/PG.h b/src/osd/PG.h index 3cf56c9d18d..fb69a6280a4 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -456,6 +456,7 @@ public: virtual void get_watchers(std::list *ls) = 0; void dump_pgstate_history(Formatter *f); + void dump_missing(Formatter *f); void get_pg_stats(std::function f); void with_heartbeat_peers(std::function f);