From: Samuel Just Date: Thu, 28 Apr 2016 20:47:48 +0000 (-0700) Subject: OSDMonitor: avoid underflow in reweight-by-utilization if max_change=1 X-Git-Tag: v0.94.7~1^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76c33decdeba83d4d977a9556e76e68fa964465f;p=ceph.git OSDMonitor: avoid underflow in reweight-by-utilization if max_change=1 Fixes: http://tracker.ceph.com/issues/15655 Signed-off-by: Samuel Just (cherry picked from commit c121bc51a5a877a49094cfbd3bd16af1f3ae5090) --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 8eadf0afe71e..f12f753b2222 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -615,7 +615,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;