int r;
out << " {\n";
out << " bucket_id " << bucket_id << "\n";
- if (arg->weight_set_size > 0) {
- r = decompile_weight_set(arg->weight_set, arg->weight_set_size, out);
+ if (arg->weight_set_positions > 0) {
+ r = decompile_weight_set(arg->weight_set, arg->weight_set_positions, out);
if (r < 0)
return r;
}
{
for (__u32 i = 0; i < arg_map.size; i++) {
if ((arg_map.args[i].ids_size == 0) &&
- (arg_map.args[i].weight_set_size == 0))
+ (arg_map.args[i].weight_set_positions == 0))
continue;
int r = decompile_choose_arg(&arg_map.args[i], -1-i, out);
if (r < 0)
int CrushCompiler::parse_weight_set(iter_t const& i, int bucket_id, crush_choose_arg *arg)
{
// -3 stands for the leading "weight_set" keyword and the enclosing [ ]
- arg->weight_set_size = i->children.size() - 3;
- arg->weight_set = (crush_weight_set *)calloc(arg->weight_set_size, sizeof(crush_weight_set));
+ arg->weight_set_positions = i->children.size() - 3;
+ arg->weight_set = (crush_weight_set *)calloc(arg->weight_set_positions, sizeof(crush_weight_set));
__u32 pos = 0;
for (iter_t p = i->children.begin(); p != i->children.end(); p++) {
int r = 0;
switch((int)p->value.id().to_long()) {
case crush_grammar::_weight_set_weights:
- if (pos < arg->weight_set_size) {
+ if (pos < arg->weight_set_positions) {
r = parse_weight_set_weights(p, bucket_id, &arg->weight_set[pos]);
pos++;
} else {
crush_choose_arg_map arg_map = choose_args.begin()->second;
for (__u32 i = 0; i < arg_map.size; i++) {
crush_choose_arg *arg = &arg_map.args[i];
- if (arg->weight_set_size == 0 &&
+ if (arg->weight_set_positions == 0 &&
arg->ids_size == 0)
continue;
- if (arg->weight_set_size != 1)
+ if (arg->weight_set_positions != 1)
return true;
if (arg->ids_size != 0)
return true;
for (auto &w : choose_args) {
crush_choose_arg_map &arg_map = w.second;
crush_choose_arg *arg = &arg_map.args[-1-bucket->id];
- for (__u32 j = 0; j < arg->weight_set_size; j++) {
+ for (__u32 j = 0; j < arg->weight_set_positions; j++) {
crush_weight_set *weight_set = &arg->weight_set[j];
weight_set->weights[position] = weight;
}
crush_choose_arg& carg = cmap.args[pos];
carg.weight_set = static_cast<crush_weight_set*>(calloc(sizeof(crush_weight_set),
size));
- carg.weight_set_size = positions;
+ carg.weight_set_positions = positions;
for (int ppos = 0; ppos < positions; ++ppos) {
carg.weight_set[ppos].weights = (__u32*)calloc(sizeof(__u32), size);
carg.weight_set[ppos].size = size;
for (auto &w : choose_args) {
crush_choose_arg_map &arg_map = w.second;
crush_choose_arg *arg = &arg_map.args[-1-bucket->id];
- for (__u32 j = 0; j < arg->weight_set_size; j++) {
+ for (__u32 j = 0; j < arg->weight_set_positions; j++) {
crush_weight_set *weight_set = &arg->weight_set[j];
weight_set->weights = (__u32*)realloc(weight_set->weights,
new_size * sizeof(__u32));
for (auto &w : choose_args) {
crush_choose_arg_map &arg_map = w.second;
crush_choose_arg *arg = &arg_map.args[-1-bucket->id];
- for (__u32 j = 0; j < arg->weight_set_size; j++) {
+ for (__u32 j = 0; j < arg->weight_set_positions; j++) {
crush_weight_set *weight_set = &arg->weight_set[j];
assert(weight_set->size - 1 == new_size);
for (__u32 k = position; k < new_size; k++)
auto& o = cmap.args[-1-original_id];
auto& n = cmap.args[-1-bno];
n.ids_size = 0; // FIXME: implement me someday
- n.weight_set_size = o.weight_set_size;
+ n.weight_set_positions = o.weight_set_positions;
n.weight_set = static_cast<crush_weight_set*>(calloc(
- n.weight_set_size, sizeof(crush_weight_set)));
- for (size_t s = 0; s < n.weight_set_size; ++s) {
+ n.weight_set_positions, sizeof(crush_weight_set)));
+ for (size_t s = 0; s < n.weight_set_positions; ++s) {
n.weight_set[s].size = copy->size;
n.weight_set[s].weights = (__u32*)calloc(copy->size, sizeof(__u32));
}
- for (size_t s = 0; s < n.weight_set_size; ++s) {
- vector<int> bucket_weights(n.weight_set_size);
+ for (size_t s = 0; s < n.weight_set_positions; ++s) {
+ vector<int> bucket_weights(n.weight_set_positions);
for (size_t i = 0; i < copy->size; ++i) {
int item = copy->items[i];
if (item >= 0) {
{
__u32 *weights;
if (encode_compat_choose_args &&
- arg_map.args[i].weight_set_size > 0) {
+ arg_map.args[i].weight_set_positions > 0) {
weights = arg_map.args[i].weight_set[0].weights;
} else {
weights = (reinterpret_cast<crush_bucket_straw2*>(crush->buckets[i]))->item_weights;
size = 0;
for (__u32 i = 0; i < arg_map.size; i++) {
crush_choose_arg *arg = &arg_map.args[i];
- if (arg->weight_set_size == 0 &&
+ if (arg->weight_set_positions == 0 &&
arg->ids_size == 0)
continue;
size++;
encode(size, bl);
for (__u32 i = 0; i < arg_map.size; i++) {
crush_choose_arg *arg = &arg_map.args[i];
- if (arg->weight_set_size == 0 &&
+ if (arg->weight_set_positions == 0 &&
arg->ids_size == 0)
continue;
encode(i, bl);
- encode(arg->weight_set_size, bl);
- for (__u32 j = 0; j < arg->weight_set_size; j++) {
+ encode(arg->weight_set_positions, bl);
+ for (__u32 j = 0; j < arg->weight_set_positions; j++) {
crush_weight_set *weight_set = &arg->weight_set[j];
encode(weight_set->size, bl);
for (__u32 k = 0; k < weight_set->size; k++)
decode(bucket_index, blp);
assert(bucket_index < arg_map.size);
crush_choose_arg *arg = &arg_map.args[bucket_index];
- decode(arg->weight_set_size, blp);
- if (arg->weight_set_size) {
+ decode(arg->weight_set_positions, blp);
+ if (arg->weight_set_positions) {
arg->weight_set = static_cast<crush_weight_set*>(calloc(
- arg->weight_set_size, sizeof(crush_weight_set)));
- for (__u32 k = 0; k < arg->weight_set_size; k++) {
+ arg->weight_set_positions, sizeof(crush_weight_set)));
+ for (__u32 k = 0; k < arg->weight_set_positions; k++) {
crush_weight_set *weight_set = &arg->weight_set[k];
decode(weight_set->size, blp);
weight_set->weights = (__u32*)calloc(
f->open_array_section(stringify(c.first).c_str());
for (__u32 i = 0; i < arg_map.size; i++) {
crush_choose_arg *arg = &arg_map.args[i];
- if (arg->weight_set_size == 0 &&
+ if (arg->weight_set_positions == 0 &&
arg->ids_size == 0)
continue;
f->open_object_section("choose_args");
int bucket_index = i;
f->dump_int("bucket_id", -1-bucket_index);
- if (arg->weight_set_size > 0) {
+ if (arg->weight_set_positions > 0) {
f->open_array_section("weight_set");
- for (__u32 j = 0; j < arg->weight_set_size; j++) {
+ for (__u32 j = 0; j < arg->weight_set_positions; j++) {
f->open_array_section("weights");
__u32 *weights = arg->weight_set[j].weights;
__u32 size = arg->weight_set[j].size;
if (b &&
bidx < (int)cmap.size &&
cmap.args[bidx].weight_set &&
- cmap.args[bidx].weight_set_size >= 1) {
+ cmap.args[bidx].weight_set_positions >= 1) {
int pos;
for (pos = 0;
pos < (int)cmap.args[bidx].weight_set[0].size &&
<< dendl;
return 0;
}
- if (carg->weight_set_size != weight.size()) {
+ if (carg->weight_set_positions != weight.size()) {
if (ss)
- *ss << "weight_set_size != " << weight.size() << " for bucket " << b->id;
- ldout(cct, 10) << __func__ << " weight_set_size != " << weight.size()
+ *ss << "weight_set_positions != " << weight.size() << " for bucket " << b->id;
+ ldout(cct, 10) << __func__ << " weight_set_positions != " << weight.size()
<< " for bucket " << b->id << dendl;
return 0;
}
void destroy_choose_args(crush_choose_arg_map arg_map) {
for (__u32 i = 0; i < arg_map.size; i++) {
crush_choose_arg *arg = &arg_map.args[i];
- for (__u32 j = 0; j < arg->weight_set_size; j++) {
+ for (__u32 j = 0; j < arg->weight_set_positions; j++) {
crush_weight_set *weight_set = &arg->weight_set[j];
free(weight_set->weights);
}
carg.ids_size = 0;
if (b && b->alg == CRUSH_BUCKET_STRAW2) {
crush_bucket_straw2 *sb = reinterpret_cast<crush_bucket_straw2*>(b);
- carg.weight_set_size = positions;
+ carg.weight_set_positions = positions;
carg.weight_set = static_cast<crush_weight_set*>(calloc(sizeof(crush_weight_set),
- carg.weight_set_size));
+ carg.weight_set_positions));
// initialize with canonical weights
for (int pos = 0; pos < positions; ++pos) {
carg.weight_set[pos].size = b->size;
}
} else {
carg.weight_set = NULL;
- carg.weight_set_size = 0;
+ carg.weight_set_positions = 0;
}
}
return true;
int get_choose_args_positions(crush_choose_arg_map cmap) {
// infer positions from other buckets
for (unsigned j = 0; j < cmap.size; ++j) {
- if (cmap.args[j].weight_set_size) {
- return cmap.args[j].weight_set_size;
+ if (cmap.args[j].weight_set_positions) {
+ return cmap.args[j].weight_set_positions;
}
}
return 1;