From: Sage Weil Date: Fri, 18 Jan 2013 05:25:21 +0000 (-0800) Subject: mon: create fail_mds_gid() helper; make 'ceph mds rm ...' more generic X-Git-Tag: v0.58~67^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e330b7ec54f89ca799ada376d5615e3c1dfc54f0;p=ceph.git mon: create fail_mds_gid() helper; make 'ceph mds rm ...' more generic Take a gid or a rank or a name. Use a nicer helper. Signed-off-by: Sage Weil --- diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index cd2dc8fa5179..74bf8b1cb8c0 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -672,10 +672,28 @@ bool MDSMonitor::preprocess_command(MMonCommand *m) return false; } +void MDSMonitor::fail_mds_gid(uint64_t gid) +{ + assert(pending_mdsmap.mds_info.count(gid)); + MDSMap::mds_info_t& info = pending_mdsmap.mds_info[gid]; + utime_t until = ceph_clock_now(g_ceph_context); + until += g_conf->mds_blacklist_interval; + + pending_mdsmap.last_failure_osd_epoch = mon->osdmon()->blacklist(info.addr, until); + mon->osdmon()->propose_pending(); + + if (info.rank >= 0) { + pending_mdsmap.up.erase(info.rank); + pending_mdsmap.failed.insert(info.rank); + } + + pending_mdsmap.mds_info.erase(gid); +} + int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg) { std::string err; - int w = strict_strtol(arg.c_str(), 10, &err); + int w = strict_strtoll(arg.c_str(), 10, &err); if (!err.empty()) { // Try to interpret the arg as an MDS name const MDSMap::mds_info_t *mds_info = mdsmap.find_by_name(arg); @@ -688,18 +706,12 @@ int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg) if (pending_mdsmap.up.count(w)) { uint64_t gid = pending_mdsmap.up[w]; - if (pending_mdsmap.mds_info.count(gid)) { - utime_t until = ceph_clock_now(g_ceph_context); - until += g_conf->mds_blacklist_interval; - MDSMap::mds_info_t& info = pending_mdsmap.mds_info[pending_mdsmap.up[w]]; - pending_mdsmap.last_failure_osd_epoch = mon->osdmon()->blacklist(info.addr, until); - mon->osdmon()->propose_pending(); - - pending_mdsmap.mds_info.erase(gid); - } - pending_mdsmap.up.erase(w); - pending_mdsmap.failed.insert(w); + if (pending_mdsmap.mds_info.count(gid)) + fail_mds_gid(gid); ss << "failed mds." << w; + } else if (pending_mdsmap.mds_info.count(w)) { + fail_mds_gid(w); + ss << "failed mds gid " << w; } return 0; } diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index d852785fa909..ba83e12dcf15 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -96,6 +96,8 @@ class MDSMonitor : public PaxosService { void get_health(list >& summary, list > *detail) const; int fail_mds(std::ostream &ss, const std::string &arg); + void fail_mds_gid(uint64_t gid); + int cluster_fail(std::ostream &ss); bool preprocess_command(MMonCommand *m);