mirror of
https://github.com/ceph/ceph
synced 2024-12-18 17:37:38 +00:00
crush: change find_roots(); add find_takes()
The find_roots() was looking for nodes referenced by 'take', but those aren't necessarily roots, which is what the callers actually want. Rename to find_takes() and add a real find_roots(). Not very efficient, but we don't care. Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
751b4bf89f
commit
683f745c14
src/crush
@ -7,7 +7,7 @@
|
||||
#define dout_subsys ceph_subsys_crush
|
||||
|
||||
|
||||
void CrushWrapper::find_roots(set<int>& roots) const
|
||||
void CrushWrapper::find_takes(set<int>& roots) const
|
||||
{
|
||||
for (unsigned i=0; i<crush->max_rules; i++) {
|
||||
crush_rule *r = crush->rules[i];
|
||||
@ -20,6 +20,17 @@ void CrushWrapper::find_roots(set<int>& roots) const
|
||||
}
|
||||
}
|
||||
|
||||
void CrushWrapper::find_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))
|
||||
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])
|
||||
|
@ -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<int>& roots) const;
|
||||
|
||||
/**
|
||||
* find tree roots
|
||||
*
|
||||
* These are parentless nodes in the map.
|
||||
*/
|
||||
void find_roots(set<int>& 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:
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user