diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index e5af5405f72..22b0524158a 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -7,7 +7,7 @@ #define dout_subsys ceph_subsys_crush -void CrushWrapper::find_roots(set& roots) const +void CrushWrapper::find_takes(set& roots) const { for (unsigned i=0; imax_rules; i++) { crush_rule *r = crush->rules[i]; @@ -20,6 +20,17 @@ void CrushWrapper::find_roots(set& roots) const } } +void CrushWrapper::find_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)) + roots.insert(b->id); + } +} + bool CrushWrapper::subtree_contains(int root, int item) const { if (root == item) @@ -86,7 +97,7 @@ int CrushWrapper::remove_item(CephContext *cct, int item) return ret; } -bool CrushWrapper::_search_item_exists(int item) +bool CrushWrapper::_search_item_exists(int item) const { for (int i = 0; i < crush->max_buckets; i++) { if (!crush->buckets[i]) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 048eb3dee5c..1cbdf1192a7 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -230,6 +230,18 @@ public: } + /** + * find tree nodes referenced by rules by a 'take' command + * + * Note that these may not be parentless roots. + */ + void find_takes(set& roots) const; + + /** + * find tree roots + * + * These are parentless nodes in the map. + */ void find_roots(set& roots) const; /** @@ -248,7 +260,7 @@ private: * @param i item * @return true if present */ - bool _search_item_exists(int i); + bool _search_item_exists(int i) const; public: /**