]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add asok command for getting subtreemap 3313/head
authorJohn Spray <john.spray@redhat.com>
Mon, 5 Jan 2015 22:32:55 +0000 (22:32 +0000)
committerJohn Spray <john.spray@redhat.com>
Fri, 9 Jan 2015 14:27:15 +0000 (14:27 +0000)
For when we want to inspect this from a test or
during debugging.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/CDir.cc
src/mds/MDS.cc
src/mds/MDS.h

index 01b61b0d17af409c945fb39473de8aae88294885..c4f0713ea26dc912665c09681bb5dd090669acf5 100644 (file)
@@ -2694,26 +2694,32 @@ void CDir::dump(Formatter *f) const
   f->dump_int("snapid_first", first);
   f->dump_bool("auth", is_auth());
 
-  // >> Only meaningful for auth
-  f->open_object_section("replica_map");
-  for (std::map<mds_rank_t, unsigned>::const_iterator i = replica_map.begin();
-       i != replica_map.end(); ++i) {
-    std::ostringstream rank_str;
-    rank_str << i->first;
-    f->dump_int(rank_str.str().c_str(), i->second);
+  // Fields only meaningful for auth
+  f->open_object_section("auth_state");
+  {
+    f->open_object_section("replica_map");
+    for (std::map<mds_rank_t, unsigned>::const_iterator i = replica_map.begin();
+         i != replica_map.end(); ++i) {
+      std::ostringstream rank_str;
+      rank_str << i->first;
+      f->dump_int(rank_str.str().c_str(), i->second);
+    }
+    f->close_section();
+    f->dump_stream("projected_version") << get_projected_version();
+    f->dump_stream("version") << get_version();
+    f->dump_stream("comitting_version") << get_committing_version();
+    f->dump_stream("comitted_version") << get_committed_version();
+  }
+  f->close_section();
+
+  // Fields only meaningful for replica
+  f->open_object_section("replica_state");
+  {
+    f->dump_stream("authority_first") << authority().first;
+    f->dump_stream("authority_second") << authority().second;
+    f->dump_stream("replica_nonce") << get_replica_nonce();
   }
   f->close_section();
-  f->dump_stream("projected_version") << get_projected_version();
-  f->dump_stream("version") << get_version();
-  f->dump_stream("comitting_version") << get_committing_version();
-  f->dump_stream("comitted_version") << get_committed_version();
-  // << Only meaningful for auth
-
-  // >> Only meaningful for replica
-  f->dump_stream("authority_first") << authority().first;
-  f->dump_stream("authority_second") << authority().second;
-  f->dump_stream("replica_nonce") << get_replica_nonce();
-  // << Only meaningful for replica
   
   f->dump_bool("is_rep", is_rep());
 
index 8c104c4a328f8072a4ab1bea092d0cfaa04c7837..f1a9c7190850308105b9b0a5713b1d1a5f255059 100644 (file)
@@ -53,6 +53,7 @@
 #include "common/Timer.h"
 
 #include "events/ESession.h"
+#include "events/ESubtreeMap.h"
 
 #include "messages/MMDSMap.h"
 #include "messages/MMDSBeacon.h"
@@ -331,6 +332,8 @@ bool MDS::asok_command(string command, cmdmap_t& cmdmap, string format,
       command_flush_path(f, path);
     } else if (command == "flush journal") {
       command_flush_journal(f);
+    } else if (command == "get subtrees") {
+      command_get_subtrees(f);
     } else if (command == "force_readonly") {
       mds_lock.Lock();
       mdcache->force_readonly();
@@ -481,6 +484,33 @@ int MDS::_command_flush_journal(std::stringstream *ss)
   return 0;
 }
 
+
+void MDS::command_get_subtrees(Formatter *f)
+{
+  assert(f != NULL);
+
+  std::list<CDir*> subtrees;
+  mdcache->list_subtrees(subtrees);
+
+  f->open_array_section("subtrees");
+  for (std::list<CDir*>::iterator i = subtrees.begin(); i != subtrees.end(); ++i) {
+    const CDir *dir = *i;
+
+    f->open_object_section("subtree");
+    {
+      f->dump_bool("is_auth", dir->is_auth());
+      f->dump_int("auth_first", dir->get_dir_auth().first);
+      f->dump_int("auth_second", dir->get_dir_auth().second);
+      f->open_object_section("dir");
+      dir->dump(f);
+      f->close_section();
+    }
+    f->close_section();
+  }
+  f->close_section();
+}
+
+
 void MDS::set_up_admin_socket()
 {
   int r;
@@ -530,6 +560,11 @@ void MDS::set_up_admin_socket()
                                     asok_hook,
                                     "Force MDS to read-only mode");
   assert(0 == r);
+  r = admin_socket->register_command("get subtrees",
+                                    "get subtrees",
+                                    asok_hook,
+                                    "Return the subtree map");
+  assert(0 == r);
 }
 
 void MDS::clean_up_admin_socket()
index f92be473249c5e3ec0cc2402e88ef69a8d9b3493..73654f4fc2f948539a946b951da641539613e37f 100644 (file)
@@ -384,6 +384,7 @@ private:
   void command_scrub_path(Formatter *f, const string& path);
   void command_flush_path(Formatter *f, const string& path);
   void command_flush_journal(Formatter *f);
+  void command_get_subtrees(Formatter *f);
  private:
   int _command_flush_journal(std::stringstream *ss);
  public: