]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: convert 'cache drop'
authorSage Weil <sage@redhat.com>
Wed, 30 Oct 2019 12:24:59 +0000 (07:24 -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 05403360d1fb60eaedef97307ea0e5ef603b9ad0..0dc905408336a11dc6e4c9941ffb85af4b397272 100644 (file)
@@ -308,6 +308,11 @@ void MDSDaemon::set_up_admin_socket()
                                      asok_hook,
                                      "dump metadata cache (optionally to a file)");
   ceph_assert(r == 0);
+  r = admin_socket->register_command("cache drop "
+                                    "name=timeout,type=CephInt,range=0,req=false",
+                                    asok_hook,
+                                    "trim cache and optionally request client to release all caps and flush the journal");
+  ceph_assert(r == 0);
   r = admin_socket->register_command("cache status",
                                      asok_hook,
                                      "show cache status");
@@ -641,7 +646,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("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 dd11155a68bb065242eba8db40c8fa620aedd3b1..6c1085415c270b1d399ba9f61e8ceb5b975a1687 100644 (file)
@@ -2619,6 +2619,21 @@ void MDSRankDispatcher::handle_asok_command(
     } else {
       r = mdcache->dump_cache(path);
     }
+  } else if (command == "cache drop") {
+    int64_t timeout = 0;
+    cmd_getval(g_ceph_context, cmdmap, "timeout", timeout);
+    finisher->queue(
+      new LambdaContext(
+       [this, on_finish, f, timeout](int r) {
+         command_cache_drop(
+           timeout, f,
+           new LambdaContext(
+             [on_finish](int r) {
+               bufferlist outbl;
+               on_finish(r, {}, outbl);
+             }));
+       }));
+    return;
   } else if (command == "cache status") {
     std::lock_guard l(mds_lock);
     mdcache->cache_status(f);
@@ -2719,21 +2734,6 @@ protected:
   JSONFormatter f;
 };
 
-class C_CacheDropExecAndReply : public C_ExecAndReply {
-public:
-  C_CacheDropExecAndReply(MDSRank *mds, const cref_t<MCommand> &m,
-                          uint64_t timeout)
-    : C_ExecAndReply(mds, m), timeout(timeout) {
-  }
-
-  void exec() override {
-    mds->command_cache_drop(timeout, &f, this);
-  }
-
-private:
-  uint64_t timeout;
-};
-
 /**
  * This function drops the mds_lock, so don't do anything with
  * MDSRank after calling it (we could have gone into shutdown): just
@@ -3551,19 +3551,7 @@ bool MDSRankDispatcher::handle_command(
   std::string prefix;
   cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
 
-  if (prefix == "cache drop") {
-    int64_t timeout;
-    if (!cmd_getval(g_ceph_context, cmdmap, "timeout", timeout)) {
-      timeout = 0;
-    }
-
-    *need_reply = false;
-    *run_later = create_async_exec_context(new C_CacheDropExecAndReply
-                                           (this, m, (uint64_t)timeout));
-    return true;
-  } else {
-    return false;
-  }
+  return false;
 }
 
 void MDSRank::command_cache_drop(uint64_t timeout, Formatter *f, Context *on_finish) {