From af1f47c0aba5612e1ea74a1d425c2383fd13d4f3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 10 Jul 2017 21:21:59 -0400 Subject: [PATCH] osd/OSDMap: remove assumption about type ids The code is assuming type==1 is in use, but it might not be. (It is usually 'chassis' by default, which is rarely used; 'host' is type usually type 2.) Remove the type check entirely and identify leaves by a child >= 0. Signed-off-by: Sage Weil --- src/osd/OSDMap.cc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index e53fe1b2cb9..ea43ae77322 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -4334,23 +4334,19 @@ void OSDMap::check_health(health_check_map_t *checks) const for (auto j = subtree_type_down[type].begin(); j != subtree_type_down[type].end(); ++j) { - if (type == 1) { - list children; - int num = crush->get_children(*j, &children); - num_osds_subtree[*j] = num; - } else { - list children; - int num = 0; - int num_children = crush->get_children(*j, &children); - if (num_children == 0) - continue; - for (auto l = children.begin(); l != children.end(); ++l) { - if (num_osds_subtree[*l] > 0) { - num = num + num_osds_subtree[*l]; - } - } - num_osds_subtree[*j] = num; + list children; + int num = 0; + int num_children = crush->get_children(*j, &children); + if (num_children == 0) + continue; + for (auto l = children.begin(); l != children.end(); ++l) { + if (*l >= 0) { + ++num; + } else if (num_osds_subtree[*l] > 0) { + num = num + num_osds_subtree[*l]; + } } + num_osds_subtree[*j] = num; } } num_down_in_osds = down_in_osds.size(); -- 2.39.5