Merge pull request #7181 from songbaisen/song5

crush: reply quickly from get_immediate_parent

Reviewed-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
Sage Weil 2016-02-08 09:16:14 -05:00
commit a981c1ecc2

View File

@ -907,8 +907,6 @@ bool CrushWrapper::check_item_present(int id) const
pair<string,string> CrushWrapper::get_immediate_parent(int id, int *_ret)
{
pair <string, string> loc;
int ret = -ENOENT;
for (int bidx = 0; bidx < crush->max_buckets; bidx++) {
crush_bucket *b = crush->buckets[bidx];
@ -918,15 +916,16 @@ pair<string,string> CrushWrapper::get_immediate_parent(int id, int *_ret)
if (b->items[i] == id) {
string parent_id = name_map[b->id];
string parent_bucket_type = type_map[b->type];
loc = make_pair(parent_bucket_type, parent_id);
ret = 0;
if (_ret)
*_ret = 0;
return make_pair(parent_bucket_type, parent_id);
}
}
if (_ret)
*_ret = ret;
*_ret = -ENOENT;
return loc;
return pair<string, string>();
}
int CrushWrapper::get_immediate_parent_id(int id, int *parent)