std::map<int64_t, crush_choose_arg_map> choose_args;
private:
- struct crush_map *crush;
+ struct crush_map *crush = nullptr;
bool have_uniform_rules = false;
/* reverse maps */
- mutable bool have_rmaps;
+ mutable bool have_rmaps = false;
mutable std::map<string, int> type_rmap, name_rmap, rule_name_rmap;
void build_rmaps() const {
if (have_rmaps) return;
CrushWrapper(const CrushWrapper& other);
const CrushWrapper& operator=(const CrushWrapper& other);
- CrushWrapper() : crush(0), have_rmaps(false) {
+ CrushWrapper() {
create();
}
~CrushWrapper() {
* Note that these may not be parentless roots.
*/
void find_takes(set<int> *roots) const;
+ void find_takes_by_rule(int rule, set<int> *roots) const;
/**
* find tree roots
/**
* return ancestor of the given type, or 0 if none
+ * can pass in a specific crush **rule** to return ancestor from that rule only
* (parent is always a bucket and thus <0)
*/
- int get_parent_of_type(int id, int type) const;
+ int get_parent_of_type(int id, int type, int rule = -1) const;
/**
* get the fully qualified location of a device by successively finding
* @return number of items, or error
*/
int get_children(int id, list<int> *children);
+ void get_children_of_type(int id,
+ int type,
+ set<int> *children,
+ bool exclude_shadow = true) const;
/**
* get failure-domain type of a specific crush rule
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 = (crush_bucket_straw2*)b;
- carg.weight_set_size = positions;
+ carg.weight_set_positions = positions;
carg.weight_set = (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;
}
}
}
choose_args.clear();
}
+ // remove choose_args for buckets that no longer exist, create them for new buckets
+ void update_choose_args(CephContext *cct);
+
// adjust choose_args_map weight, preserving the hierarchical summation
// property. used by callers optimizing layouts by tweaking weights.
int _choose_args_adjust_item_weight_in_bucket(
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;