to reduce code redundance...
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
}
}
-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)
if (have_rmaps)
rule_name_rmap[name] = i;
}
+ bool is_shadow_item(int id) const {
+ const char *name = get_item_name(id);
+ return name && !is_valid_crush_name(name);
+ }
/**
* These are parentless nodes in the map that are not shadow
* items for device classes.
*/
- void find_nonshadow_roots(set<int>& roots) const;
+ void find_nonshadow_roots(set<int>& roots) const {
+ set<int> all;
+ find_roots(all);
+ for (auto& p: all) {
+ if (!is_shadow_item(p)) {
+ roots.insert(p);
+ }
+ }
+ }
/**
* see if an item is contained within a subtree