From c121bc51a5a877a49094cfbd3bd16af1f3ae5090 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 --- 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 7ec912b6d1e..0e725afe8dc 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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; -- 2.47.3