]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/balancer: normalize weight-set weights to sum to target weight
authorSage Weil <sage@redhat.com>
Tue, 26 Sep 2017 22:36:06 +0000 (18:36 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Nov 2017 12:28:49 +0000 (07:28 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/balancer/module.py

index 612fe6b4a60afc95a0150f3082f1439374c254c7..9b00922cac46b75fb4319aeb95d3c421eed5aa73 100644 (file)
@@ -646,6 +646,18 @@ class Module(MgrModule):
                                    new_weight)
                     next_ws[osd] = new_weight
 
+                # normalize weights under this root
+                root_weight = crush.get_item_weight(pe.root_ids[root])
+                root_sum = sum(b for a,b in next_ws.iteritems()
+                               if a in target.keys())
+                if root_sum > 0 and root_weight > 0:
+                    factor = root_sum / root_weight
+                    self.log.debug('normalizing root %s %d, weight %f, ws sum %f, factor %f',
+                                   root, pe.root_ids[root], root_weight,
+                                   root_sum, factor)
+                    for osd in actual.keys():
+                        next_ws[osd] = next_ws[osd] / factor
+
             # recalc
             plan.compat_ws = copy.deepcopy(next_ws)
             next_ms = plan.final_state()