"mds", "*", "cli,rest")
};
-// FIXME: reinstate issue_caps, try_eval,
-// *if* it makes sense to do so (or should these be admin socket things?)
-
-/* This function DOES put the passed message before returning*/
-void MDSDaemon::handle_command(MMonCommand *m)
-{
- bufferlist outbl;
- _handle_command_legacy(m->cmd);
- m->put();
-}
int MDSDaemon::_handle_command(
const cmdmap_t &cmdmap,
return r;
}
-/**
- * Legacy "mds tell", takes a simple array of args
- */
-int MDSDaemon::_handle_command_legacy(std::vector<std::string> args)
-{
- dout(10) << "handle_command args: " << args << dendl;
- if (args[0] == "injectargs") {
- if (args.size() < 2) {
- derr << "Ignoring empty injectargs!" << dendl;
- }
- else {
- std::ostringstream oss;
- mds_lock.Unlock();
- g_conf->injectargs(args[1], &oss);
- mds_lock.Lock();
- derr << "injectargs:" << dendl;
- derr << oss.str() << dendl;
- }
- }
- else if (args[0] == "exit") {
- suicide();
- }
- else if (args[0] == "respawn") {
- respawn();
- }
- else if (args[0] == "cpu_profiler") {
- ostringstream ss;
- cpu_profiler_handle_command(args, ss);
- clog->info() << ss.str();
- }
- else if (args[0] == "heap") {
- if (!ceph_using_tcmalloc())
- clog->info() << "tcmalloc not enabled, can't use heap profiler commands";
- else {
- ostringstream ss;
- vector<std::string> cmdargs;
- cmdargs.insert(cmdargs.begin(), args.begin()+1, args.end());
- ceph_heap_profiler_handle_command(cmdargs, ss);
- clog->info() << ss.str();
- }
- } else {
- if (!(mds_rank && mds_rank->handle_command_legacy(args))) {
- dout(0) << "unrecognized command! " << args << dendl;
- }
- }
-
- return 0;
-}
-
/* This function deletes the passed message before returning. */
void MDSDaemon::handle_mds_map(MMDSMap *m)
handle_mds_map(static_cast<MMDSMap*>(m));
break;
- // misc
- case MSG_MON_COMMAND:
- ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
- handle_command(static_cast<MMonCommand*>(m));
- break;
-
// OSD
case MSG_COMMAND:
handle_command(static_cast<MCommand*>(m));
m->put();
break;
+ case MSG_MON_COMMAND:
+ ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
+ clog->warn() << "dropping `mds tell` command from legacy monitor";
+ m->put();
+ break;
+
default:
return false;
}
last_client_mdsmap_bcast = mdsmap->get_epoch();
}
-
-bool MDSRankDispatcher::handle_command_legacy(std::vector<std::string> args)
-{
- if (args[0] == "dumpcache") {
- if (args.size() > 1)
- mdcache->dump_cache(args[1].c_str());
- else
- mdcache->dump_cache();
- }
- else if (args[0] == "session" && args[1] == "kill") {
- std::stringstream ss;
- bool killed = kill_session(strtol(args[2].c_str(), 0, 10), false, ss);
- if (!killed)
- dout(15) << ss.str() << dendl;
-
- } else if (args[0] == "issue_caps") {
- long inum = strtol(args[1].c_str(), 0, 10);
- CInode *in = mdcache->get_inode(inodeno_t(inum));
- if (in) {
- bool r = locker->issue_caps(in);
- dout(20) << "called issue_caps on inode " << inum
- << " with result " << r << dendl;
- } else dout(15) << "inode " << inum << " not in mdcache!" << dendl;
- } else if (args[0] == "try_eval") {
- long inum = strtol(args[1].c_str(), 0, 10);
- int mask = strtol(args[2].c_str(), 0, 10);
- CInode * ino = mdcache->get_inode(inodeno_t(inum));
- if (ino) {
- locker->try_eval(ino, mask);
- dout(20) << "try_eval(" << inum << ", " << mask << ")" << dendl;
- } else dout(15) << "inode " << inum << " not in mdcache!" << dendl;
- } else if (args[0] == "fragment_dir") {
- if (mdsmap->allows_dirfrags()) {
- if (args.size() == 4) {
- filepath fp(args[1].c_str());
- CInode *in = mdcache->cache_traverse(fp);
- if (in) {
- frag_t fg;
- if (fg.parse(args[2].c_str())) {
- CDir *dir = in->get_dirfrag(fg);
- if (dir) {
- if (dir->is_auth()) {
- int by = atoi(args[3].c_str());
- if (by)
- mdcache->split_dir(dir, by);
- else
- dout(0) << "need to split by >0 bits" << dendl;
- } else dout(0) << "dir " << dir->dirfrag() << " not auth" << dendl;
- } else dout(0) << "dir " << in->ino() << " " << fg << " dne" << dendl;
- } else dout(0) << " frag " << args[2] << " does not parse" << dendl;
- } else dout(0) << "path " << fp << " not found" << dendl;
- } else dout(0) << "bad syntax" << dendl;
- } else dout(0) << "dirfrags are disallowed by the mds map!" << dendl;
- } else if (args[0] == "merge_dir") {
- if (args.size() == 3) {
- filepath fp(args[1].c_str());
- CInode *in = mdcache->cache_traverse(fp);
- if (in) {
- frag_t fg;
- if (fg.parse(args[2].c_str())) {
- mdcache->merge_dir(in, fg);
- } else dout(0) << " frag " << args[2] << " does not parse" << dendl;
- } else dout(0) << "path " << fp << " not found" << dendl;
- } else dout(0) << "bad syntax" << dendl;
- } else if (args[0] == "export_dir") {
- if (args.size() == 3) {
- filepath fp(args[1].c_str());
- mds_rank_t target = mds_rank_t(atoi(args[2].c_str()));
- if (target != whoami && mdsmap->is_up(target) && mdsmap->is_in(target)) {
- CInode *in = mdcache->cache_traverse(fp);
- if (in) {
- CDir *dir = in->get_dirfrag(frag_t());
- if (dir && dir->is_auth()) {
- mdcache->migrator->export_dir(dir, target);
- } else dout(0) << "bad export_dir path dirfrag frag_t() or dir not auth" << dendl;
- } else dout(0) << "bad export_dir path" << dendl;
- } else dout(0) << "bad export_dir target syntax" << dendl;
- } else dout(0) << "bad export_dir syntax" << dendl;
- } else {
- return false;
- }
-
- return true;
-}
-
MDSRankDispatcher::MDSRankDispatcher(
mds_rank_t whoami_,
Mutex &mds_lock_,