]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: hide device class shadow roots from tree dumper
authorSage Weil <sage@redhat.com>
Thu, 29 Jun 2017 13:45:13 +0000 (09:45 -0400)
committerSage Weil <sage@redhat.com>
Sun, 9 Jul 2017 02:35:21 +0000 (22:35 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushTreeDumper.h
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index 40691c697d3a75487eb0414ded0470b597b5ec4c..70c48c83a6834e160198e1a55981d7276023eb2e 100644 (file)
@@ -64,7 +64,7 @@ namespace CrushTreeDumper {
   class Dumper : public list<Item> {
   public:
     explicit Dumper(const CrushWrapper *crush_) : crush(crush_) {
-      crush->find_roots(roots);
+      crush->find_nonshadow_roots(roots);
       root = roots.begin();
     }
 
index 6a0017df96d7cc3b7150a29a6ca38b2fbee4fdf8..0f0b5d5fc33ae154c41a0627af2ac7b7372472d8 100644 (file)
@@ -300,6 +300,21 @@ void CrushWrapper::find_roots(set<int>& roots) const
   }
 }
 
+void CrushWrapper::find_nonshadow_roots(set<int>& roots) const
+{
+  for (int i = 0; i < crush->max_buckets; i++) {
+    if (!crush->buckets[i])
+      continue;
+    crush_bucket *b = crush->buckets[i];
+    if (_search_item_exists(b->id))
+      continue;
+    const char *name = get_item_name(b->id);
+    if (name && !is_valid_crush_name(name))
+      continue;
+    roots.insert(b->id);
+  }
+}
+
 bool CrushWrapper::subtree_contains(int root, int item) const
 {
   if (root == item)
index b5bfebb765780f44c2b002ff5a246047f2e7d37c..81db9dc8b8bb6cd07178e58e00208e996e19748f 100644 (file)
@@ -562,6 +562,14 @@ public:
    */
   void find_roots(set<int>& roots) const;
 
+  /**
+   * find tree roots that are not shadow (device class) items
+   *
+   * These are parentless nodes in the map that are not shadow
+   * items for device classes.
+   */
+  void find_nonshadow_roots(set<int>& roots) const;
+
   /**
    * see if an item is contained within a subtree
    *