From: Sage Weil Date: Thu, 29 Jun 2017 13:45:13 +0000 (-0400) Subject: crush: hide device class shadow roots from tree dumper X-Git-Tag: v12.1.1~97^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=116cf759c86ca9ca7d80769b2096953516f357cb;p=ceph.git crush: hide device class shadow roots from tree dumper Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushTreeDumper.h b/src/crush/CrushTreeDumper.h index 40691c697d3a..70c48c83a683 100644 --- a/src/crush/CrushTreeDumper.h +++ b/src/crush/CrushTreeDumper.h @@ -64,7 +64,7 @@ namespace CrushTreeDumper { class Dumper : public list { public: explicit Dumper(const CrushWrapper *crush_) : crush(crush_) { - crush->find_roots(roots); + crush->find_nonshadow_roots(roots); root = roots.begin(); } diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 6a0017df96d7..0f0b5d5fc33a 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -300,6 +300,21 @@ void CrushWrapper::find_roots(set& roots) const } } +void CrushWrapper::find_nonshadow_roots(set& 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) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index b5bfebb76578..81db9dc8b8bb 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -562,6 +562,14 @@ public: */ void find_roots(set& 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& roots) const; + /** * see if an item is contained within a subtree *