void do_rule(int rule, int x, vector<int>& out, int maxout,
const vector<__u32>& weight) const {
int rawout[maxout];
- int numrep = crush_do_rule(crush, rule, x, rawout, maxout, &weight[0]);
+ int numrep = crush_do_rule(crush, rule, x, rawout, maxout, &weight[0], weight.size());
if (numrep < 0)
numrep = 0;
out.resize(numrep);
* true if device is marked "out" (failed, fully offloaded)
* of the cluster
*/
-static int is_out(const struct crush_map *map, const __u32 *weight, int item, int x)
+static int is_out(const struct crush_map *map, const __u32 *weight, int weight_max, int item, int x)
{
+ if (item >= weight_max)
+ return 1;
if (weight[item] >= 0x10000)
return 0;
if (weight[item] == 0)
*/
static int crush_choose(const struct crush_map *map,
struct crush_bucket *bucket,
- const __u32 *weight,
+ const __u32 *weight, int weight_max,
int x, int numrep, int type,
int *out, int outpos,
int firstn, int recurse_to_leaf,
if (item < 0) {
if (crush_choose(map,
map->buckets[-1-item],
- weight,
+ weight, weight_max,
x, outpos+1, 0,
out2, outpos,
firstn, 0,
if (!reject) {
/* out? */
if (itemtype == 0)
- reject = is_out(map, weight,
+ reject = is_out(map, weight, weight_max,
item, x);
else
reject = 0;
*/
int crush_do_rule(const struct crush_map *map,
int ruleno, int x, int *result, int result_max,
- const __u32 *weight)
+ const __u32 *weight, int weight_max)
{
int result_len;
int a[CRUSH_MAX_SET];
j = 0;
osize += crush_choose(map,
map->buckets[-1-w[i]],
- weight,
+ weight, weight_max,
x, numrep,
curstep->arg2,
o+osize, j,
extern int crush_do_rule(const struct crush_map *map,
int ruleno,
int x, int *result, int result_max,
- const __u32 *weights);
+ const __u32 *weights, int weight_max);
#endif