From: Colin Patrick McCabe Date: Mon, 15 Nov 2010 22:47:44 +0000 (-0800) Subject: Add ./ceph osd tell dump_missing X-Git-Tag: v0.24~177^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7075115baed1fa2183cf65709ee64edcf5dd727;p=ceph.git Add ./ceph osd tell dump_missing Add a command that tells the OSD to dump its missing set for all PGs to a file. This should be useful for debugging multi-OSD scenarios. Signed-off-by: Colin McCabe --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 6ed6f69e4342..c26af2e255df 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1863,7 +1863,45 @@ void OSD::handle_command(MMonCommand *m) ss << g_conf.name << " stopped profiler"; logclient.log(LOG_INFO, ss); } + else if (m->cmd.size() == 2 && m->cmd[0] == "dump_missing") { + const string &file_name(m->cmd[1]); + std::ofstream fout(file_name.c_str()); + if (!fout.is_open()) { + stringstream ss; + ss << "failed to open file '" << file_name << "'"; + logclient.log(LOG_INFO, ss); + goto done; + } + + std::set keys; + for (hash_map::const_iterator pg_map_e = pg_map.begin(); + pg_map_e != pg_map.end(); ++pg_map_e) { + keys.insert(pg_map_e->first); + } + + fout << "*** osd " << whoami << ": dump_missing ***" << std::endl; + for (std::set ::iterator p = keys.begin(); + p != keys.end(); ++p) { + hash_map::iterator q = pg_map.find(*p); + assert(q != pg_map.end()); + PG *pg = q->second; + pg->lock(); + + fout << *pg << std::endl; + std::map::iterator mend = pg->missing.missing.end(); + std::map::iterator m = pg->missing.missing.begin(); + for (; m != mend; ++m) { + fout << m->first << " -> " << m->second << std::endl; + } + pg->unlock(); + fout << std::endl; + } + + fout.close(); + } else dout(0) << "unrecognized command! " << m->cmd << dendl; + +done: m->put(); }