Skip to content

Commit

Permalink
Merge pull request #9416: hammer: mon/OSDMonistor: improve reweight_b…
Browse files Browse the repository at this point in the history
…y_utilization() logic

Reviewed-by: Nathan Cutler <ncutler@suse.com>
  • Loading branch information
smithfarm committed Jun 27, 2016
2 parents e6a8fbc + bf14d65 commit 0817777
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/mon/OSDMonitor.cc
Expand Up @@ -463,10 +463,16 @@ void OSDMonitor::update_logger()
}

struct Sorter {
bool operator()(std::pair<int,float> l,
std::pair<int,float> r) {
return l.second > r.second;
}

double average_util;

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

bool operator()(std::pair<int,float> l, std::pair<int,float> r) {
return abs(l.second - average_util) > abs(r.second - average_util);
}
};

/* Assign a lower weight to overloaded OSDs.
Expand Down Expand Up @@ -595,8 +601,9 @@ int OSDMonitor::reweight_by_utilization(int oload,
util_by_osd.push_back(osd_util);
}

// sort and iterate from most to least utilized
std::sort(util_by_osd.begin(), util_by_osd.end(), Sorter());
// sort by absolute deviation from the mean utilization,
// in descending order.
std::sort(util_by_osd.begin(), util_by_osd.end(), Sorter(average_util));

OSDMap::Incremental newinc;

Expand Down Expand Up @@ -1487,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 @@ -1530,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 0817777

Please sign in to comment.