]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/balancer: avoid pulling pg_dump twice 32266/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 16 Dec 2019 05:54:50 +0000 (13:54 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 16 Dec 2019 06:14:59 +0000 (14:14 +0800)
For large cluster with thousands of osds/pgs, it may take
seconds even mitutes to refresh the relevant stats.
Since we already have pulling them down at initialization,
make a direct use of them whenever possible.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/pybind/mgr/balancer/module.py

index 9ea28735e7c50a0bc58abfcee7894c4cb7c05379..041938a7471b3b629c29c61ca1317af8404ae573 100644 (file)
@@ -954,7 +954,7 @@ class Module(MgrModule):
         inc = plan.inc
         total_did = 0
         left = max_optimizations
-        osdmap_dump = self.get_osdmap().dump()
+        osdmap_dump = ms.osdmap_dump
         pools_with_pg_merge = [p['pool_name'] for p in osdmap_dump.get('pools', [])
                                if p['pg_num'] > p['pg_num_target']]
         crush_rule_by_pool_name = dict((p['pool_name'], p['crush_rule']) for p in osdmap_dump.get('pools', []))
@@ -984,7 +984,7 @@ class Module(MgrModule):
             # since scrubbing activities have significant impacts on performance
             pool_ids = list(p['pool'] for p in pool_dump if p['pool_name'] in it)
             num_pg_active_clean = 0
-            pg_dump = self.get('pg_dump')
+            pg_dump = ms.pg_dump
             for p in pg_dump['pg_stats']:
                 pg_pool = p['pgid'].split('.')[0]
                 if len(pool_ids) and int(pg_pool) not in pool_ids: