]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: convert 'session ls' and 'client ls'
authorSage Weil <sage@redhat.com>
Wed, 30 Oct 2019 02:15:24 +0000 (21:15 -0500)
committerSage Weil <sage@redhat.com>
Fri, 15 Nov 2019 18:42:40 +0000 (12:42 -0600)
This adds/moves the filtering to the asok version.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc

index a91bbbc730da2d6967c9f1198771b018483f7c89..316eee9ad4eb0ad0139fea6b6247f5e535ce51ec 100644 (file)
@@ -302,6 +302,14 @@ void MDSDaemon::set_up_admin_socket()
                                      asok_hook,
                                      "dump snapshots");
   ceph_assert(r == 0);
+  r = admin_socket->register_command("session ls name=filters,type=CephString,n=N,req=false",
+                                    asok_hook,
+                                    "List client sessions based on a filter");
+  ceph_assert(r == 0);
+  r = admin_socket->register_command("client ls name=filters,type=CephString,n=N,req=false",
+                                    asok_hook,
+                                    "List client sessions based on a filter");
+  ceph_assert(r == 0);
   r = admin_socket->register_command("session evict name=filters,type=CephString,n=N,req=false",
                                     asok_hook,
                                     "Evict client session(s) based on a filter");
@@ -592,8 +600,6 @@ void MDSDaemon::handle_command(const cref_t<MCommand> &m)
 const std::vector<MDSDaemon::MDSCommand>& MDSDaemon::get_commands()
 {
   static const std::vector<MDSCommand> commands = {
-    MDSCommand("session ls name=filters,type=CephString,n=N,req=false", "List client sessions"),
-    MDSCommand("client ls name=filters,type=CephString,n=N,req=false", "List client sessions"),
     MDSCommand("session config name=client_id,type=CephInt name=option,type=CephString name=value,type=CephString,req=false",
        "Config a client session"),
     MDSCommand("client config name=client_id,type=CephInt name=option,type=CephString name=value,type=CephString,req=false",
index 54ed67e1219e00d42cc55b6d040e167853c39e80..46624cca3453ff1555c9ff3c527984f296e99c5a 100644 (file)
@@ -2476,12 +2476,17 @@ void MDSRankDispatcher::handle_asok_command(
       dout(4) << __func__ << ": waiting for OSD epoch " << target_epoch << dendl;
       cond.wait();
     }
-  } else if (command == "session ls") {
+  } else if (command == "session ls" ||
+            command == "client ls") {
     std::lock_guard l(mds_lock);
-
-    heartbeat_reset();
-
-    dump_sessions(SessionFilter(), f);
+    std::vector<std::string> filter_args;
+    cmd_getval(g_ceph_context, cmdmap, "filters", filter_args);
+    SessionFilter filter;
+    r = filter.parse(filter_args, &ss);
+    if (r != 0) {
+      goto out;
+    }
+    dump_sessions(filter, f);
   } else if (command == "session evict" ||
             command == "client evict") {
     std::lock_guard l(mds_lock);
@@ -3531,21 +3536,7 @@ bool MDSRankDispatcher::handle_command(
   std::string prefix;
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
-  if (prefix == "session ls" || prefix == "client ls") {
-    std::vector<std::string> filter_args;
-    cmd_getval(g_ceph_context, cmdmap, "filters", filter_args);
-
-    SessionFilter filter;
-    *r = filter.parse(filter_args, ss);
-    if (*r != 0) {
-      return true;
-    }
-
-    JSONFormatter f(true);
-    dump_sessions(filter, &f);
-    f.flush(*ds);
-    return true;
-  } else if (prefix == "session config" || prefix == "client config") {
+  if (prefix == "session config" || prefix == "client config") {
     int64_t client_id;
     std::string option;
     std::string value;