From: Sage Weil Date: Wed, 6 Aug 2014 15:35:07 +0000 (-0700) Subject: mon/OSDMonitor: adjust weights up, when possible X-Git-Tag: v0.86~244^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8b971e94d431d4536bb8fba155992516c00a4778;p=ceph.git mon/OSDMonitor: adjust weights up, when possible Note when OSDs are underloaded, as well. If that is the case, adjust the OSD reweight value if, if possible. (It won't always be possible since weights are capped at 1.) Note that we set the underload threshold to the average, as we want to aggressively adjust weights up (back to 1.0) whenever possible. This gets us a more efficient mapping calculation and reduces the amount of "noise" in the weights. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 0870e7208ea1..c23503acdd15 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -457,13 +457,13 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, } const PGMap &pgm = mon->pgmon()->pg_map; - double average_util, overload_util; vector pgs_by_osd(osdmap.get_max_osd()); unsigned num_pg_copies = 0; unsigned num_osds = pgm.osd_stat.size(); // Avoid putting a small number (or 0) in the denominator when calculating // average_util + double average_util; if (by_pg) { // by pg mapping for (ceph::unordered_map::const_iterator p = @@ -489,7 +489,6 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, } average_util = (double)num_pg_copies / (double)num_osds; - overload_util = average_util * (double)oload / 100.0; } else { // by osd utilization if (pgm.osd_sum.kb < 1024) { @@ -509,9 +508,14 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, } average_util = (double)pgm.osd_sum.kb_used / (double)pgm.osd_sum.kb; - overload_util = average_util * (double)oload / 100.0; } + // adjust down only if we are above the threshold + double overload_util = average_util * (double)oload / 100.0; + + // but aggressively adjust weights up whenever possible. + double underload_util = average_util; + ostringstream oss; char buf[128]; snprintf(buf, sizeof(buf), "average_util: %04f, overload_util: %04f. ", @@ -545,6 +549,23 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, oss << buf << sep; changed = true; } + if (util <= underload_util) { + // assign a higher weight.. if we can. + unsigned weight = osdmap.get_weight(p->first); + unsigned new_weight = (unsigned)((average_util / util) * (float)weight); + if (new_weight > 0x10000) + new_weight = 0x10000; + if (new_weight > weight) { + sep = ", "; + pending_inc.new_weight[p->first] = new_weight; + char buf[128]; + snprintf(buf, sizeof(buf), "%d [%04f -> %04f]", p->first, + (float)weight / (float)0x10000, + (float)new_weight / (float)0x10000); + oss << buf << sep; + changed = true; + } + } } if (sep.empty()) { oss << "(none)";