From 1fdd277ffb96f61c6e52da1af383bd25b3807af1 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Thu, 11 Oct 2018 02:26:29 -0400 Subject: [PATCH] mds: make timeout parameter optional for "cache drop" Fixes: http://tracker.ceph.com/issues/36694 Signed-off-by: Venky Shankar (cherry picked from commit 73459619747046d38df5f4ec6707db12dce77317) Conflicts: src/mds/MDSDaemon.cc --- src/mds/MDSDaemon.cc | 5 ++--- src/mds/MDSRank.cc | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 76d658ddde309..09bc9b5b88281 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -251,7 +251,7 @@ void MDSDaemon::set_up_admin_socket() "show cache status"); assert(r == 0); r = admin_socket->register_command("cache drop", - "cache drop name=timeout,type=CephInt,range=1", + "cache drop name=timeout,type=CephInt,range=0,req=false", asok_hook, "drop cache"); assert(r == 0); @@ -666,7 +666,6 @@ void MDSDaemon::handle_command(MCommand *m) m->put(); } - struct MDSCommand { string cmdstring; string helpstring; @@ -724,7 +723,7 @@ COMMAND("heap " \ "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \ "show heap usage info (available only if compiled with tcmalloc)", \ "mds", "*", "cli,rest") -COMMAND("cache drop name=timeout,type=CephInt,range=1", "trim cache and optionally " +COMMAND("cache drop name=timeout,type=CephInt,range=0,req=false", "trim cache and optionally " "request client to release all caps and flush the journal", "mds", "r", "cli,rest") }; diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index b99e46283ea23..9ef53b14f5002 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -279,6 +279,10 @@ private: } void start_timer() { + if (!timeout) { + return; + } + timer_task = new FunctionContext([this](int _) { timer_task = nullptr; complete(-ETIMEDOUT); @@ -2513,7 +2517,7 @@ bool MDSRankDispatcher::handle_asok_command(std::string_view command, } else if (command == "cache drop") { int64_t timeout; if (!cmd_getval(g_ceph_context, cmdmap, "timeout", timeout)) { - return false; + timeout = 0; } C_SaferCond cond; @@ -3380,7 +3384,7 @@ bool MDSRankDispatcher::handle_command( } else if (prefix == "cache drop") { int64_t timeout; if (!cmd_getval(g_ceph_context, cmdmap, "timeout", timeout)) { - return false; + timeout = 0; } JSONFormatter *f = new JSONFormatter(true); -- 2.39.5