]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: convert 'damage ls' and 'damage rm'
authorSage Weil <sage@redhat.com>
Wed, 30 Oct 2019 12:08:58 +0000 (07:08 -0500)
committerSage Weil <sage@redhat.com>
Thu, 12 Dec 2019 19:31:26 +0000 (13:31 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc

index 32cd36f15e663107ff129443e381b430d4be39f4..05403360d1fb60eaedef97307ea0e5ef603b9ad0 100644 (file)
@@ -364,6 +364,15 @@ void MDSDaemon::set_up_admin_socket()
                                     asok_hook,
                                     "Config a CephFS client session");
   assert(r == 0);
+  r = admin_socket->register_command("damage ls",
+                                    asok_hook,
+                                    "List detected metadata damage");
+  assert(r == 0);
+  r = admin_socket->register_command("damage rm "
+                                    "name=damage_id,type=CephInt",
+                                    asok_hook,
+                                    "Remove a damage table entry");
+  assert(r == 0);
   r = admin_socket->register_command("osdmap barrier name=target_epoch,type=CephInt",
                                     asok_hook,
                                     "Wait until the MDS has this OSD map epoch");
@@ -632,8 +641,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("damage ls", "List detected metadata damage"),
-    MDSCommand("damage rm name=damage_id,type=CephInt", "Remove a damage table entry"),
     MDSCommand("cache drop name=timeout,type=CephInt,range=0,req=false", "trim cache and optionally request client to release all caps and flush the journal"),
   };
   return commands;
index 849985188fda57cd2c1718b377e3159aa8a37907..dd11155a68bb065242eba8db40c8fa620aedd3b1 100644 (file)
@@ -2654,6 +2654,17 @@ void MDSRankDispatcher::handle_asok_command(
     command_openfiles_ls(f);
   } else if (command == "dump inode") {
     command_dump_inode(f, cmdmap, ss);
+  } else if (command == "damage ls") {
+    std::lock_guard l(mds_lock);
+    damage_table.dump(f);
+  } else if (command == "damage rm") {
+    std::lock_guard l(mds_lock);
+    damage_entry_id_t id = 0;
+    if (!cmd_getval(g_ceph_context, cmdmap, "damage_id", (int64_t&)id)) {
+      r = -EINVAL;
+      goto out;
+    }
+    damage_table.erase(id);
   } else {
     r = -ENOSYS;
   }
@@ -3540,22 +3551,7 @@ bool MDSRankDispatcher::handle_command(
   std::string prefix;
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
-  if (prefix == "damage ls") {
-    JSONFormatter f(true);
-    damage_table.dump(&f);
-    f.flush(*ds);
-    return true;
-  } else if (prefix == "damage rm") {
-    damage_entry_id_t id = 0;
-    bool got = cmd_getval(g_ceph_context, cmdmap, "damage_id", (int64_t&)id);
-    if (!got) {
-      *r = -EINVAL;
-      return true;
-    }
-
-    damage_table.erase(id);
-    return true;
-  } else if (prefix == "cache drop") {
+  if (prefix == "cache drop") {
     int64_t timeout;
     if (!cmd_getval(g_ceph_context, cmdmap, "timeout", timeout)) {
       timeout = 0;