crush: clean up get_immediate_parent_id()

This is a follow-up cleanup of 9d908c14f6

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
xie xingguo 2017-07-27 08:08:41 +08:00
parent 0f23574234
commit 4736037394
2 changed files with 3 additions and 16 deletions

View File

@ -1327,19 +1327,14 @@ pair<string,string> CrushWrapper::get_immediate_parent(int id, int *_ret)
return pair<string, string>();
}
int CrushWrapper::get_immediate_parent_id(int id,
int *parent,
parent_type_t choice) const
int CrushWrapper::get_immediate_parent_id(int id, int *parent) const
{
for (int bidx = 0; bidx < crush->max_buckets; bidx++) {
crush_bucket *b = crush->buckets[bidx];
if (b == 0)
continue;
if (choice == PARENT_NONSHADOW && is_shadow_item(b->id)) {
if (is_shadow_item(b->id))
continue;
} else if (choice == PARENT_SHADOW && !is_shadow_item(b->id)) {
continue;
}
for (unsigned i = 0; i < b->size; i++) {
if (b->items[i] == id) {
*parent = b->id;

View File

@ -662,15 +662,7 @@ public:
*/
pair<string,string> get_immediate_parent(int id, int *ret = NULL);
typedef enum {
PARENT_NONSHADOW,
PARENT_SHADOW,
PARENT_ALL,
} parent_type_t;
int get_immediate_parent_id(int id,
int *parent,
parent_type_t choice = PARENT_NONSHADOW) const;
int get_immediate_parent_id(int id, int *parent) const;
/**
* return ancestor of the given type, or 0 if none