class CrushWrapper {
mutable Mutex mapper_lock;
public:
- struct crush_map *crush;
std::map<int32_t, string> type_map; /* bucket/device type names */
std::map<int32_t, string> name_map; /* bucket/device names */
std::map<int32_t, string> rule_name_map;
+private:
+ struct crush_map *crush;
/* reverse maps */
bool have_rmaps;
std::map<string, int> type_rmap, name_rmap, rule_name_rmap;
-
-private:
void build_rmaps() {
if (have_rmaps) return;
build_rmap(type_map, type_rmap);
}
}
}
-
- crush_rule *rule = crush_make_rule(4, 0, 123, 1, 20);
- assert(rule);
- crush_rule_set_step(rule, 0, CRUSH_RULE_SET_CHOOSELEAF_TRIES, 10, 0);
- crush_rule_set_step(rule, 1, CRUSH_RULE_TAKE, rootno, 0);
- crush_rule_set_step(rule, 2,
- CRUSH_RULE_CHOOSELEAF_INDEP,
- CRUSH_CHOOSE_N,
- 1);
- crush_rule_set_step(rule, 3, CRUSH_RULE_EMIT, 0, 0);
- int rno = crush_add_rule(c->crush, rule, -1);
- c->set_rule_name(rno, "data");
+ int ret;
+ int ruleno = 0;
+ int ruleset = 0;
+ ruleno = ruleset;
+ ret = c->add_rule(4, ruleset, 123, 1, 20, ruleno);
+ assert(ret == ruleno);
+ ret = c->set_rule_step(ruleno, 0, CRUSH_RULE_SET_CHOOSELEAF_TRIES, 10, 0);
+ assert(ret == 0);
+ ret = c->set_rule_step(ruleno, 1, CRUSH_RULE_TAKE, rootno, 0);
+ assert(ret == 0);
+ ret = c->set_rule_step(ruleno, 2, CRUSH_RULE_CHOOSELEAF_INDEP, CRUSH_CHOOSE_N, 1);
+ assert(ret == 0);
+ ret = c->set_rule_step(ruleno, 3, CRUSH_RULE_EMIT, 0, 0);
+ assert(ret == 0);
+ c->set_rule_name(ruleno, "data");
if (false) {
Formatter *f = new_formatter("json-pretty");
c->dump_tree(weight, &cout, NULL);
// need more retries to get 9/9 hosts for x in 0..99
- c->crush->choose_total_tries = 100;
+ c->set_choose_total_tries(100);
for (int x = 0; x < 100; ++x) {
vector<int> out;
c->do_rule(0, x, out, 9, weight);
weight[i] = 0;
c->dump_tree(weight, &cout, NULL);
- c->crush->choose_total_tries = 100;
+ c->set_choose_total_tries(100);
for (int x = 0; x < 100; ++x) {
vector<int> out;
c->do_rule(0, x, out, 7, weight);
TEST(CRUSH, indep_out_progressive) {
CrushWrapper *c = build_indep_map(g_ceph_context, 3, 3, 3);
- c->crush->choose_total_tries = 100;
+ c->set_choose_total_tries(100);
vector<__u32> tweight(c->get_max_devices(), 0x10000);
c->dump_tree(tweight, &cout, NULL);
dout(2) << " item " << items[j] << " weight " << weights[j] << dendl;
}
- crush_bucket *b = crush_make_bucket(buckettype, CRUSH_HASH_DEFAULT, type, j, items, weights);
- assert(b);
int id;
- int r = crush_add_bucket(crush.crush, 0, b, &id);
+ int r = crush.add_bucket(0, buckettype, CRUSH_HASH_DEFAULT, type, j, items, weights, &id);
if (r < 0) {
dout(2) << "Couldn't add bucket: " << cpp_strerror(r) << dendl;
}