From: xie xingguo Date: Mon, 14 Aug 2017 06:12:16 +0000 (+0800) Subject: crush: fix bucket index to weight-set X-Git-Tag: v12.2.0~15^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8bcd8115d4f0c43909061113b96164e75693902c;p=ceph.git crush: fix bucket index to weight-set Signed-off-by: xie xingguo (cherry picked from commit 859b066adf5de02a5b127d9177f792b80616cbea) --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 76c6afe60a5c..a5519e2d4aa5 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1703,25 +1703,28 @@ int CrushWrapper::add_bucket( weights); assert(b); int r = crush_add_bucket(crush, bucketno, b, idout); + int pos = -1 - *idout; for (auto& p : choose_args) { crush_choose_arg_map& cmap = p.second; if (cmap.args) { - if ((int)cmap.size <= *idout) { + if ((int)cmap.size <= pos) { cmap.args = (crush_choose_arg*)realloc( cmap.args, - sizeof(crush_choose_arg) * (*idout + 1)); + sizeof(crush_choose_arg) * (pos + 1)); + assert(cmap.args); memset(&cmap.args[cmap.size], 0, - sizeof(crush_choose_arg) * (*idout + 1 - cmap.size)); - cmap.size = *idout + 1; + sizeof(crush_choose_arg) * (pos + 1 - cmap.size)); + cmap.size = pos + 1; } } else { cmap.args = (crush_choose_arg*)calloc(sizeof(crush_choose_arg), - *idout + 1); - cmap.size = *idout + 1; + pos + 1); + assert(cmap.args); + cmap.size = pos + 1; } if (size > 0) { int positions = get_choose_args_positions(cmap); - crush_choose_arg& carg = cmap.args[*idout]; + crush_choose_arg& carg = cmap.args[pos]; carg.weight_set = (crush_weight_set*)calloc(sizeof(crush_weight_set), size); carg.weight_set_size = positions;