From: xie xingguo Date: Tue, 31 May 2016 22:40:05 +0000 (-0700) Subject: mon/OSDMonitor: avoid potential expensive grace calculation X-Git-Tag: v0.94.8~28^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=23498a9620f792cd099dba028c5bdf96b1a625be;p=ceph.git mon/OSDMonitor: avoid potential expensive grace calculation The grace calculation during check_failure() is now very complicated and time-consuming. Therefore we shall skip this when it is possible. Signed-off-by: xie xingguo (cherry picked from commit 3557903d5d57642179b2ae137bedc389974b1956) Conflicts: src/mon/OSDMonitor.cc Resolved by choosing the move-to-top implementation. Removed unused vars. --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c647c60017d..5c7ef72e7a3 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -1494,6 +1494,13 @@ void OSDMonitor::check_failures(utime_t now) bool OSDMonitor::check_failure(utime_t now, int target_osd, failure_info_t& fi) { + // already pending failure? + if (pending_inc.new_state.count(target_osd) && + pending_inc.new_state[target_osd] & CEPH_OSD_UP) { + dout(10) << " already pending failure" << dendl; + return true; + } + utime_t orig_grace(g_conf->osd_heartbeat_grace, 0); utime_t max_failed_since = fi.get_failed_since(); utime_t failed_for = now - max_failed_since; @@ -1537,13 +1544,6 @@ bool OSDMonitor::check_failure(utime_t now, int target_osd, failure_info_t& fi) << grace << " grace (" << orig_grace << " + " << my_grace << " + " << peer_grace << "), max_failed_since " << max_failed_since << dendl; - // already pending failure? - if (pending_inc.new_state.count(target_osd) && - pending_inc.new_state[target_osd] & CEPH_OSD_UP) { - dout(10) << " already pending failure" << dendl; - return true; - } - if (failed_for >= grace && ((int)fi.reporters.size() >= g_conf->mon_osd_min_down_reporters) && (fi.num_reports >= g_conf->mon_osd_min_down_reports)) {