]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Crush when get immediate parent quickly reply. 7181/head
authorsongbaisen <song.baisen@zte.com.cn>
Mon, 11 Jan 2016 10:37:50 +0000 (18:37 +0800)
committersongbaisen <song.baisen@zte.com.cn>
Wed, 3 Feb 2016 03:04:22 +0000 (11:04 +0800)
Fixes: #14334
Signed-off-by: song baisen <song.baisen@zte.com.cn>
src/crush/CrushWrapper.cc

index ba365dd78d3eb69f3b253a6dbb88c7c8c7ff2e12..db17e1d0038a7601a4bde821fdf2071d7a2b2d8e 100644 (file)
@@ -881,8 +881,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];
@@ -892,15 +890,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)