]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/OSDMonitor: make blacklist expire configurable; fix potential races
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 24 Jun 2017 06:50:57 +0000 (14:50 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 26 Jun 2017 12:23:28 +0000 (20:23 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/common/config_opts.h
src/mon/OSDMonitor.cc

index 443ef8c1a8719afd17a6b6ad3e4c76b5d14a4dc0..61b0f5b7e9f415c7d74efd2480ef20b6f272e3ff 100644 (file)
@@ -393,6 +393,7 @@ OPTION(mon_keyvaluedb, OPT_STR, "rocksdb")   // type of keyvaluedb backend
 
 // UNSAFE -- TESTING ONLY! Allows addition of a cache tier with preexisting snaps
 OPTION(mon_debug_unsafe_allow_tier_with_nonempty_snaps, OPT_BOOL, false)
+OPTION(mon_osd_blacklist_default_expire, OPT_DOUBLE, 60*60) // default one hour
 
 OPTION(paxos_stash_full_interval, OPT_INT, 25)   // how often (in commits) to stash a full copy of the PaxosService state
 OPTION(paxos_max_join_drift, OPT_INT, 10) // max paxos iterations before we must first sync the monitor stores
index 1872219fcad5ba352f6269d1a366b0e67e5b61ec..6d9e7eac4a2c6bb683f00b1e598503630e3ca076 100644 (file)
@@ -9317,10 +9317,21 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
        utime_t expires = ceph_clock_now();
        double d;
        // default one hour
-       cmd_getval(g_ceph_context, cmdmap, "expire", d, double(60*60));
+       cmd_getval(g_ceph_context, cmdmap, "expire", d,
+          g_conf->mon_osd_blacklist_default_expire);
        expires += d;
 
        pending_inc.new_blacklist[addr] = expires;
+
+        {
+          // cancel any pending un-blacklisting request too
+          auto it = std::find(pending_inc.old_blacklist.begin(),
+            pending_inc.old_blacklist.end(), addr);
+          if (it != pending_inc.old_blacklist.end()) {
+            pending_inc.old_blacklist.erase(it);
+          }
+        }
+
        ss << "blacklisting " << addr << " until " << expires << " (" << d << " sec)";
        getline(ss, rs);
        wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,