From: Sage Weil Date: Wed, 30 Oct 2019 12:08:58 +0000 (-0500) Subject: mds: convert 'damage ls' and 'damage rm' X-Git-Tag: v15.1.0~519^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5ae0effbe38f3aeecefa159bd94034da6aa70df6;p=ceph.git mds: convert 'damage ls' and 'damage rm' Signed-off-by: Sage Weil --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 32cd36f15e66..05403360d1fb 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -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 &m) const std::vector& MDSDaemon::get_commands() { static const std::vector 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; diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 849985188fda..dd11155a68bb 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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;