if (!name_exists(q->second)) {
ldout(cct, 5) << "insert_item creating bucket " << q->second << dendl;
int empty = 0, newid;
- int r = add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, p->first, 1, &cur, &empty, &newid);
+ int r = add_bucket(0, 0,
+ CRUSH_HASH_DEFAULT, p->first, 1, &cur, &empty, &newid);
if (r < 0) {
ldout(cct, 1) << "add_bucket failure error: " << cpp_strerror(r) << dendl;
return r;
bool is_v2_rule(unsigned ruleid) const;
bool is_v3_rule(unsigned ruleid) const;
+ // default bucket types
+ unsigned get_default_bucket_alg() const {
+ return CRUSH_BUCKET_STRAW;
+ }
+
// bucket types
int get_num_type_names() const {
return type_map.size();
/* modifiers */
int add_bucket(int bucketno, int alg, int hash, int type, int size,
int *items, int *weights, int *idout) {
- if (type == 0)
- return -EINVAL;
+ if (alg == 0) {
+ alg = get_default_bucket_alg();
+ if (alg == 0)
+ return -EINVAL;
+ }
crush_bucket *b = crush_make_bucket(crush, alg, hash, type, size, items, weights);
assert(b);
return crush_add_bucket(crush, bucketno, b, idout);
goto reply;
}
int bucketno;
- err = newcrush.add_bucket(0, CRUSH_BUCKET_STRAW,
- CRUSH_HASH_DEFAULT, type, 0, NULL,
- NULL, &bucketno);
+ err = newcrush.add_bucket(0, 0,
+ CRUSH_HASH_DEFAULT, type, 0, NULL,
+ NULL, &bucketno);
if (err < 0) {
ss << "add_bucket error: '" << cpp_strerror(err) << "'";
goto reply;
// root
int root_type = _build_crush_types(crush);
int rootid;
- int r = crush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT,
+ int r = crush.add_bucket(0, 0, CRUSH_HASH_DEFAULT,
root_type, 0, NULL, NULL, &rootid);
assert(r == 0);
crush.set_item_name(rootid, "default");
// root
int root_type = _build_crush_types(crush);
int rootid;
- int r = crush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT,
+ int r = crush.add_bucket(0, 0,
+ CRUSH_HASH_DEFAULT,
root_type, 0, NULL, NULL, &rootid);
assert(r == 0);
crush.set_item_name(rootid, "default");