mon/OSDMonitor: make blacklist expire configurable; fix potential races

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
xie xingguo 2017-06-24 14:50:57 +08:00
parent c4923a7603
commit 9205dd2059
2 changed files with 13 additions and 1 deletions

View 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

View 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,