]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: remove unnecessary sanity check 8681/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 21 Apr 2016 07:51:41 +0000 (15:51 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 21 Apr 2016 07:54:51 +0000 (15:54 +0800)
We have done sanity check with bucket_exists() above, so these
checks are redundant and less effcient.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/crush/CrushWrapper.cc

index 16f61dfb7467ce0eec2c36e8c50089a9c8b5269e..490c79fc97a1c48d99227e56eca553ba8c2dfd84 100644 (file)
@@ -645,8 +645,8 @@ int CrushWrapper::insert_item(CephContext *cct, int item, float weight, string n
       return -EINVAL;
     }
 
+    // we have done sanity check above
     crush_bucket *b = get_bucket(id);
-    assert(b);
 
     if (p->first != b->type) {
       ldout(cct, 1) << "insert_item existing bucket has type "
@@ -808,8 +808,6 @@ int CrushWrapper::get_item_weight_in_loc(int id, const map<string,string> &loc)
     if (!bucket_exists(bid))
       continue;
     crush_bucket *b = get_bucket(bid);
-    if ( b == NULL)
-      continue;
     for (unsigned int i = 0; i < b->size; i++) {
       if (b->items[i] == id) {
        return crush_get_bucket_item_weight(b, i);
@@ -851,8 +849,6 @@ int CrushWrapper::adjust_item_weight_in_loc(CephContext *cct, int id, int weight
     if (!bucket_exists(bid))
       continue;
     crush_bucket *b = get_bucket(bid);
-    if ( b == NULL)
-      continue;
     for (unsigned int i = 0; i < b->size; i++) {
       if (b->items[i] == id) {
        int diff = crush_bucket_adjust_item_weight(crush, b, id, weight);