]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: improve reweight_by_utilization() logic
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 26 Apr 2016 03:13:32 +0000 (11:13 +0800)
committerSage Weil <sage@redhat.com>
Wed, 4 May 2016 13:06:19 +0000 (09:06 -0400)
By calling reweight_by_utilization() method, we are aiming at an evener result
of utilization among all osds. To achieve this, we shall decrease weights of
osds which are currently overloaded, and try to increase weights of osds which
are currently underloaded when it is possible.
However, we can't do this all at a time in order to avoid a massive pg migrations
between osds. Thus we introduce a max_osds limit to smooth the progress.

The problem here is that we have sorted the utilization of all osds in a descending
manner and we always try to decrease the weights of the most overloaded osds
since they are most likely to encounter a nearfull/full transition soon, but
we won't increase the weights from the most underloaded(least utilized by contrast)
at the same time, which I think is not quite reasonable.

Actually, the best thing would probably be to iterate over teh low and high osds
in parallel, and do the ones that are furthest from the average first.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit e7a32534ebc9e27f955ff2d7a8d1db511383301e)

src/mon/OSDMonitor.cc

index 43e529afba729374fd4937e2f2c6d38dc26c2a37..3c97fce0d8bf7837b09ac9856585370783bde6ce 100644 (file)
@@ -599,10 +599,13 @@ 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(), [](std::pair<int, float> l, std::pair<int, float> r) {
-    return l.second > r.second;
-  });
+  // sort by absolute deviation from the mean utilization,
+  // in descending order.
+  std::sort(util_by_osd.begin(), util_by_osd.end(),
+    [average_util](std::pair<int, float> l, std::pair<int, float> r) {
+      return abs(l.second - average_util) > abs(r.second - average_util);
+    }
+  );
 
   OSDMap::Incremental newinc;