]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: use bucket_exists() for item sanity checks
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 21 Apr 2016 05:56:31 +0000 (13:56 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 21 Apr 2016 07:49:07 +0000 (15:49 +0800)
This is because get_bucket() never returns 0 on error,
it always returns a non-zero value. So if you
assert(get_bucket(item)), you always get a postive answer.

Replace existence check for a specific item

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

index dc6280ee8507e6843a95c3904c5f08ea8ac52edf..16f61dfb7467ce0eec2c36e8c50089a9c8b5269e 100644 (file)
@@ -471,8 +471,8 @@ bool CrushWrapper::check_item_loc(CephContext *cct, int item, const map<string,s
       return false;
     }
 
+    assert(bucket_exists(id));
     crush_bucket *b = get_bucket(id);
-    assert(b);
 
     // see if item exists in this bucket
     for (unsigned j=0; j<b->size; j++) {
index 411b2b53364d107b128688f5bbb2deac37fe0d5f..f926ffeed3c2f8474b56a49ceda53277b06a3535 100644 (file)
@@ -905,7 +905,7 @@ private:
       return (-EINVAL);
 
     // check that the bucket that we want to detach exists
-    assert( get_bucket(item) );
+    assert(bucket_exists(item));
 
     // get the bucket's weight
     crush_bucket *b = get_bucket(item);