]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: dump mds session info
authorSage Weil <sage@inktank.com>
Fri, 9 Nov 2012 20:01:50 +0000 (12:01 -0800)
committerSage Weil <sage@inktank.com>
Mon, 12 Nov 2012 23:06:10 +0000 (15:06 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/Makefile.am
src/client/Client.cc
src/client/Client.h
src/client/MetaSession.cc [new file with mode: 0644]
src/client/MetaSession.h

index 2acfd05b684d1054a19f395e7cecf5c56f34fa36..fef3dea6496e47d99f87859aeb19fbb71ef7ff86 100644 (file)
@@ -1352,6 +1352,7 @@ libclient_la_SOURCES = \
        client/Dentry.cc \
        client/MetaRequest.cc \
        client/SnapRealm.cc \
+       client/MetaSession.cc \
        client/Trace.cc
 libclient_la_LIBADD = libosdc.la $(LIBEDIT_LIBS)
 noinst_LTLIBRARIES += libclient.la
index 6a6d656196f039839d996f1b964eca951a579a36..e9675bab3696b7d9b444c7b345e2769ce87ecfda 100644 (file)
@@ -115,6 +115,8 @@ bool Client::CommandHook::call(std::string command, std::string args, bufferlist
   m_client->client_lock.Lock();
   if (command == "mds_requests")
     m_client->dump_mds_requests(&formatter);
+  else if (command == "mds_sessions")
+    m_client->dump_mds_sessions(&formatter);
   else if (command == "dump_cache")
     m_client->dump_cache(&formatter);
   else
@@ -371,6 +373,13 @@ int Client::init()
     lderr(cct) << "error registering admin socket command: "
               << cpp_strerror(-ret) << dendl;
   }
+  ret = admin_socket->register_command("mds_sessions",
+                                      &m_command_hook,
+                                      "show mds session state");
+  if (ret < 0) {
+    lderr(cct) << "error registering admin socket command: "
+              << cpp_strerror(-ret) << dendl;
+  }
   ret = admin_socket->register_command("dump_cache",
                                       &m_command_hook,
                                       "show in-memory metadata cache contents");
@@ -1102,6 +1111,22 @@ void Client::connect_mds_targets(int mds)
   }
 }
 
+void Client::dump_mds_sessions(Formatter *f)
+{
+  f->open_array_section("open_sessions");
+  for (map<int,MetaSession*>::const_iterator p = mds_sessions.begin(); p != mds_sessions.end(); ++p) {
+    f->open_object_section("session");
+    p->second->dump(f);
+    f->close_section();
+  }
+  f->close_section();
+  f->open_array_section("opening_sessions");
+  for (map<int,list<Cond*> >::const_iterator p = waiting_for_session.begin(); p != waiting_for_session.end(); ++p) {
+    f->dump_int("mds", p->first);
+  }
+  f->close_section();
+  f->dump_int("mdsmap_epoch", mdsmap->get_epoch());
+}
 void Client::dump_mds_requests(Formatter *f)
 {
   for (map<tid_t, MetaRequest*>::iterator p = mds_requests.begin();
index 840124d741b2c260685e7ea00fe9fc5fd64432ae..f6f288a5bba0f62020b0abc716fb8d58559f869c 100644 (file)
@@ -244,6 +244,7 @@ public:
   set<int>                 failed_mds;
 
   void dump_mds_requests(Formatter *f);
+  void dump_mds_sessions(Formatter *f);
 
   int make_request(MetaRequest *req, int uid, int gid,
                   //MClientRequest *req, int uid, int gid,
diff --git a/src/client/MetaSession.cc b/src/client/MetaSession.cc
new file mode 100644 (file)
index 0000000..36338c0
--- /dev/null
@@ -0,0 +1,28 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "include/types.h"
+
+#include "MetaSession.h"
+
+#include "common/Formatter.h"
+
+void MetaSession::dump(Formatter *f) const
+{
+  f->dump_int("mds", mds_num);
+  f->dump_stream("addr") << inst.addr;
+  f->dump_unsigned("seq", seq);
+  f->dump_unsigned("cap_gen", cap_gen);
+  f->dump_stream("cap_ttl") << cap_ttl;
+  f->dump_stream("last_cap_renew_request") << last_cap_renew_request;
+  f->dump_unsigned("cap_renew_seq", cap_renew_seq);
+  f->dump_int("num_caps", num_caps);
+  f->dump_int("closing", (int)closing);
+  f->dump_int("was_stale", (int)was_stale);
+}
+
+MetaSession::~MetaSession()
+{
+  if (release)
+    release->put();
+}
index 52449bfde18774df3510b716a8db6550879430b1..20a7a588d73279020ebd2c54b3a84b6369460c23 100644 (file)
@@ -1,3 +1,6 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
 #ifndef CEPH_CLIENT_METASESSION_H
 #define CEPH_CLIENT_METASESSION_H
 
@@ -35,10 +38,9 @@ struct MetaSession {
   
   MetaSession() : mds_num(-1), seq(0), cap_gen(0), cap_renew_seq(0), num_caps(0),
                 closing(false), was_stale(false), release(NULL) {}
-  ~MetaSession() {
-    if (release)
-      release->put();
-  }
+  ~MetaSession();
+
+  void dump(Formatter *f) const;
 };
 
 #endif