]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: adjust weights up, when possible
authorSage Weil <sage@redhat.com>
Wed, 6 Aug 2014 15:35:07 +0000 (08:35 -0700)
committerSage Weil <sage@redhat.com>
Tue, 19 Aug 2014 15:16:41 +0000 (08:16 -0700)
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 <sage@redhat.com>
src/mon/OSDMonitor.cc

index 0870e7208ea1a207c7bfe3e6adcd97ba93b3075f..c23503acdd15dd5ff107ad65a476f206478cb2a1 100644 (file)
@@ -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<int> 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<pg_t,pg_stat_t>::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)";