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");
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;
};
} 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);
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
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) {