]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: remove assumption about type ids
authorSage Weil <sage@redhat.com>
Tue, 11 Jul 2017 01:21:59 +0000 (21:21 -0400)
committerSage Weil <sage@redhat.com>
Thu, 13 Jul 2017 16:14:26 +0000 (12:14 -0400)
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 <sage@redhat.com>
src/osd/OSDMap.cc

index e53fe1b2cb98e99c0afc0c4c90c5d17cd442f06d..ea43ae773228f7a156a18e799a17da291cee7d23 100644 (file)
@@ -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<int> children;
-          int num = crush->get_children(*j, &children);
-          num_osds_subtree[*j] = num;
-        } else {
-          list<int> 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<int> 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();