]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: use Session::dump method uniformly
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 2 Aug 2019 20:34:56 +0000 (13:34 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 13 Sep 2019 00:42:03 +0000 (17:42 -0700)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSRank.cc
src/mds/Server.cc
src/mds/SessionMap.cc
src/mds/SessionMap.h
src/mds/mdstypes.cc

index e5a0d4d08bdb4dc03c330c7ffce4e70895304ad8..4fbeff427aa2277e847d2c526c34b0aeb7b51e87 100644 (file)
@@ -2761,39 +2761,18 @@ void MDSRankDispatcher::dump_sessions(const SessionFilter &filter, Formatter *f)
 {
   // Dump sessions, decorated with recovery/replay status
   f->open_array_section("sessions");
-  const ceph::unordered_map<entity_name_t, Session*> session_map = sessionmap.get_sessions();
-  for (auto& p : session_map) {
-    if (!p.first.is_client()) {
+  for (auto& [name, s] : sessionmap.get_sessions()) {
+    if (!name.is_client()) {
       continue;
     }
 
-    Session *s = p.second;
-
     if (!filter.match(*s, std::bind(&Server::waiting_for_reconnect, server, std::placeholders::_1))) {
       continue;
     }
 
-    f->open_object_section("session");
-    f->dump_int("id", p.first.num());
-
-    f->dump_int("num_leases", s->leases.size());
-    f->dump_int("num_caps", s->caps.size());
-
-    f->dump_string("state", s->get_state_name());
-    if (s->is_open() || s->is_stale()) {
-      f->dump_unsigned("request_load_avg", s->get_load_avg());
-    }
-    f->dump_float("uptime", s->get_session_uptime());
-    f->dump_int("replay_requests", is_clientreplay() ? s->get_request_count() : 0);
-    f->dump_unsigned("completed_requests", s->get_num_completed_requests());
-    f->dump_bool("reconnecting", server->waiting_for_reconnect(p.first.num()));
-    f->dump_stream("inst") << s->info.inst;
-    f->open_object_section("client_metadata");
-    s->info.client_metadata.dump(f);
-    f->close_section(); // client_metadata
-    f->close_section(); //session
+    f->dump_object("session", *s);
   }
-  f->close_section(); //sessions
+  f->close_section(); // sessions
 }
 
 void MDSRank::command_scrub_start(Formatter *f,
index a75811a23999c9ff4ada8ea7e69a9c2b8a74a07a..d710e917091bd49ed3b9f87eaab4cfa0d7e55c0e 100644 (file)
@@ -1207,6 +1207,7 @@ void Server::reconnect_clients(MDSContext *reconnect_done_)
   for (auto session : sessions) {
     if (session->is_open()) {
       client_reconnect_gather.insert(session->get_client());
+      session->set_reconnecting(true);
       session->last_cap_renew = now;
     }
   }
@@ -1356,6 +1357,7 @@ void Server::handle_client_reconnect(const cref_t<MClientReconnect> &m)
 
     // remove from gather set
     client_reconnect_gather.erase(from);
+    session->set_reconnecting(false);
     if (client_reconnect_gather.empty())
       reconnect_gather_finish();
   }
index 27e79e1215deec833da3b79e612c80a571f55f01..a64ec838b953f855fdec1a5770c8f799620aa8f2 100644 (file)
@@ -570,21 +570,32 @@ void SessionMapStore::decode_legacy(bufferlist::const_iterator& p)
   }
 }
 
+void Session::dump(Formatter *f) const
+{
+  f->dump_int("id", info.inst.name.num());
+  f->dump_object("entity", info.inst);
+  f->dump_string("state", get_state_name());
+  f->dump_int("num_leases", leases.size());
+  f->dump_int("num_caps", caps.size());
+  if (is_open() || is_stale()) {
+    f->dump_unsigned("request_load_avg", get_load_avg());
+  }
+  f->dump_float("uptime", get_session_uptime());
+  f->dump_unsigned("requests_in_flight", get_request_count());
+  f->dump_unsigned("completed_requests", get_num_completed_requests());
+  f->dump_bool("reconnecting", reconnecting);
+  f->dump_object("recall_caps", recall_caps);
+  f->dump_object("release_caps", release_caps);
+  f->dump_object("recall_caps_throttle", recall_caps_throttle);
+  f->dump_object("recall_caps_throttle2o", recall_caps_throttle2o);
+  info.dump(f);
+}
+
 void SessionMapStore::dump(Formatter *f) const
 {
-  f->open_array_section("Sessions");
-  for (ceph::unordered_map<entity_name_t,Session*>::const_iterator p = session_map.begin();
-       p != session_map.end();
-       ++p)  {
-    f->open_object_section("Session");
-    f->open_object_section("entity name");
-    p->first.dump(f);
-    f->close_section(); // entity name
-    f->dump_string("state", p->second->get_state_name());
-    f->open_object_section("Session info");
-    p->second->info.dump(f);
-    f->close_section(); // Session info
-    f->close_section(); // Session
+  f->open_array_section("sessions");
+  for (const auto& p : session_map) {
+    f->dump_object("session", *p.second);
   }
   f->close_section(); // Sessions
 }
index 2e30433436bc7d57085067f12df10cc8039a2c04..cbc6dee982e11680338afec2d6c12a5076361e19 100644 (file)
@@ -96,8 +96,11 @@ public:
     }
   }
 
+  void dump(Formatter *f) const;
+
 private:
   int state = STATE_CLOSED;
+  bool reconnecting = false;
   uint64_t state_seq = 0;
   int importing_count = 0;
   friend class SessionMap;
@@ -155,6 +158,9 @@ public:
       state_seq++;
     }
   }
+
+  void set_reconnecting(bool s) { reconnecting = s; }
+
   void decode(bufferlist::const_iterator &p);
   template<typename T>
   void set_client_metadata(T&& meta)
index d65bfb5c00803ab38c6726b8613fb0781439e122..d044166883f039455a384ad73b187539a8b61350 100644 (file)
@@ -463,8 +463,8 @@ void client_metadata_t::decode(bufferlist::const_iterator& p)
 void client_metadata_t::dump(Formatter *f) const
 {
   f->dump_stream("features") << features;
-  for (const auto& p : kv_map)
-    f->dump_string(p.first.c_str(), p.second);
+  for (const auto& [name, val] : kv_map)
+    f->dump_string(name.c_str(), val);
 }
 
 /*
@@ -521,41 +521,33 @@ void session_info_t::dump(Formatter *f) const
   f->dump_stream("inst") << inst;
 
   f->open_array_section("completed_requests");
-  for (map<ceph_tid_t,inodeno_t>::const_iterator p = completed_requests.begin();
-       p != completed_requests.end();
-       ++p) {
+  for (const auto& [tid, ino] : completed_requests) {
     f->open_object_section("request");
-    f->dump_unsigned("tid", p->first);
-    f->dump_stream("created_ino") << p->second;
+    f->dump_unsigned("tid", tid);
+    f->dump_stream("created_ino") << ino;
     f->close_section();
   }
   f->close_section();
 
   f->open_array_section("prealloc_inos");
-  for (interval_set<inodeno_t>::const_iterator p = prealloc_inos.begin();
-       p != prealloc_inos.end();
-       ++p) {
+  for (const auto& [start, len] : prealloc_inos) {
     f->open_object_section("ino_range");
-    f->dump_unsigned("start", p.get_start());
-    f->dump_unsigned("length", p.get_len());
+    f->dump_unsigned("start", start);
+    f->dump_unsigned("length", len);
     f->close_section();
   }
   f->close_section();
 
   f->open_array_section("used_inos");
-  for (interval_set<inodeno_t>::const_iterator p = used_inos.begin();
-       p != used_inos.end();
-       ++p) {
+  for (const auto& [start, len] : used_inos) {
     f->open_object_section("ino_range");
-    f->dump_unsigned("start", p.get_start());
-    f->dump_unsigned("length", p.get_len());
+    f->dump_unsigned("start", start);
+    f->dump_unsigned("length", len);
     f->close_section();
   }
   f->close_section();
 
-  f->open_array_section("client_metadata");
-  client_metadata.dump(f);
-  f->close_section();
+  f->dump_object("client_metadata", client_metadata);
 }
 
 void session_info_t::generate_test_instances(std::list<session_info_t*>& ls)