From 9205dd205946042045fd6c455b06ee878937082a Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 24 Jun 2017 14:50:57 +0800 Subject: [PATCH] mon/OSDMonitor: make blacklist expire configurable; fix potential races Signed-off-by: xie xingguo --- src/common/config_opts.h | 1 + src/mon/OSDMonitor.cc | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 443ef8c1a87..61b0f5b7e9f 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1872219fcad..6d9e7eac4a2 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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,