]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add ./ceph osd tell <osd-num> dump_missing <out>
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 15 Nov 2010 22:47:44 +0000 (14:47 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 15 Nov 2010 22:47:44 +0000 (14:47 -0800)
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 <colinm@hq.newdream.net>
src/osd/OSD.cc

index 6ed6f69e4342e7011c1ea30d9b587a9e73bc9ac5..c26af2e255df74e890e491306cc040caae8f5c73 100644 (file)
@@ -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 <pg_t> keys;
+    for (hash_map<pg_t, PG*>::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 <pg_t>::iterator p = keys.begin();
+        p != keys.end(); ++p) {
+      hash_map<pg_t, PG*>::iterator q = pg_map.find(*p);
+      assert(q != pg_map.end());
+      PG *pg = q->second;
+      pg->lock();
+
+      fout << *pg << std::endl;
+      std::map<sobject_t, PG::Missing::item>::iterator mend = pg->missing.missing.end();
+      std::map<sobject_t, PG::Missing::item>::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();
 }