Skip to content

Commit

Permalink
mon/OSDMonitor: avoid potential expensive grace calculation
Browse files Browse the repository at this point in the history
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 <xie.xingguo@zte.com.cn>
(cherry picked from commit 3557903)

 Conflicts:
	src/mon/OSDMonitor.cc

Resolved by choosing the move-to-top implementation. Removed unused vars.
  • Loading branch information
xiexingguo authored and chardan committed Jun 2, 2016
1 parent cc847f7 commit bf14d65
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mon/OSDMonitor.cc
Expand Up @@ -466,7 +466,7 @@ struct Sorter {

double average_util;

Sorter(const average_util_)
Sorter(const double average_util_)
: average_util(average_util_)
{}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit bf14d65

Please sign in to comment.