]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMonitor: avoid underflow in reweight-by-utilization if max_change=1 9006/head
authorSamuel Just <sjust@redhat.com>
Thu, 28 Apr 2016 20:47:48 +0000 (13:47 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 2 May 2016 22:50:35 +0000 (15:50 -0700)
Fixes: http://tracker.ceph.com/issues/15655
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit c121bc51a5a877a49094cfbd3bd16af1f3ae5090)

src/mon/OSDMonitor.cc

index f9cf0fd80272e030d7a3513eb707e7267b54eadc..9c88c7eed7d74336d9aee151b4c69a0aba815fbb 100644 (file)
@@ -621,7 +621,8 @@ int OSDMonitor::reweight_by_utilization(int oload,
       // to represent e.g. differing storage capacities
       unsigned weight = osdmap.get_weight(p->first);
       unsigned new_weight = (unsigned)((average_util / util) * (float)weight);
-      new_weight = MAX(new_weight, weight - max_change);
+      if (weight > max_change)
+       new_weight = MAX(new_weight, weight - max_change);
       newinc.new_weight[p->first] = new_weight;
       if (!dry_run) {
        pending_inc.new_weight[p->first] = new_weight;