]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: enforce unique name in mdsmap
authorSage Weil <sage@inktank.com>
Fri, 18 Jan 2013 05:38:49 +0000 (21:38 -0800)
committerSage Weil <sage@inktank.com>
Fri, 18 Jan 2013 05:45:36 +0000 (21:45 -0800)
Add 'mds enforce unique name' option, defaulting to true.

If set, when an MDS boots, it will kick any previous mds with the same
name from the mdsmap.  This is possibly less confusing for users.  If
an mds daemon restarts, it will immediately replace its previous
instantiation.

Two misconfigured daemons running with the same name will fight over
the same role.

Fixes: #3857
Signed-off-by: Sage Weil <sage@inktank.com>
src/common/config_opts.h
src/mds/MDSMap.h
src/mon/MDSMonitor.cc

index a5df112576f9c12d523fbd451302ab1453a4ca5d..c611041f5917a07aaebc8c3dffc5b2b2c7faf284 100644 (file)
@@ -213,6 +213,7 @@ OPTION(mds_dir_max_commit_size, OPT_INT, 90) // MB
 OPTION(mds_decay_halflife, OPT_FLOAT, 5)
 OPTION(mds_beacon_interval, OPT_FLOAT, 4)
 OPTION(mds_beacon_grace, OPT_FLOAT, 15)
+OPTION(mds_enforce_unique_name, OPT_BOOL, true)
 OPTION(mds_blacklist_interval, OPT_FLOAT, 24.0*60.0)  // how long to blacklist failed nodes
 OPTION(mds_session_timeout, OPT_FLOAT, 60)    // cap bits and leases time out if client idle
 OPTION(mds_session_autoclose, OPT_FLOAT, 300) // autoclose idle session
index 3a83ed88b08e34abbba00e709aa894fbae7a35b2..1314156f2d3253bc34a4c6331d20535a04e649c5 100644 (file)
@@ -256,6 +256,16 @@ public:
     assert(up.count(m) && mds_info.count(up[m]));
     return mds_info[up[m]];
   }
+  uint64_t find_mds_gid_by_name(const string& s) {
+    for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+        p != mds_info.end();
+        ++p) {
+      if (p->second.name == s) {
+       return p->first;
+      }
+    }
+    return 0;
+  }
 
   // counts
   unsigned get_num_in_mds() {
index 74bf8b1cb8c08d62ea0e615fbf5fd5b38301acc9..7585e42c5ea7fa4ef5ef019c9e16a58fd66f285e 100644 (file)
@@ -354,6 +354,13 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m)
 
   // boot?
   if (state == MDSMap::STATE_BOOT) {
+    // zap previous instance of this name?
+    if (g_conf->mds_enforce_unique_name) {
+      while (uint64_t existing = pending_mdsmap.find_mds_gid_by_name(m->get_name())) {
+       fail_mds_gid(existing);
+      }
+    }
+
     // add
     MDSMap::mds_info_t& info = pending_mdsmap.mds_info[gid];
     info.global_id = gid;
@@ -376,7 +383,6 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m)
       }
     }
 
-
     // initialize the beacon timer
     last_beacon[gid].stamp = ceph_clock_now(g_ceph_context);
     last_beacon[gid].seq = seq;
@@ -676,6 +682,8 @@ 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];
+  dout(10) << "fail_mds_gid " << gid << " mds." << info.name << " rank " << info.rank << dendl;
+
   utime_t until = ceph_clock_now(g_ceph_context);
   until += g_conf->mds_blacklist_interval;