From 76c33decdeba83d4d977a9556e76e68fa964465f Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 28 Apr 2016 13:47:48 -0700 Subject: [PATCH] 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) --- src/mon/OSDMonitor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.47.3