}
/* modifiers */
- int add_bucket(int bucketno, int alg, int type, int size,
+ int add_bucket(int bucketno, int alg, int hash, int type, int size,
int *items, int *weights) {
- crush_bucket *b = crush_make_bucket(alg, type, size, items, weights);
+ crush_bucket *b = crush_make_bucket(alg, hash, type, size, items, weights);
return crush_add_bucket(crush, bucketno, b);
}
::encode(crush->buckets[i]->id, bl);
::encode(crush->buckets[i]->type, bl);
- ::encode(crush->buckets[i]->hash, bl);
::encode(crush->buckets[i]->alg, bl);
+ ::encode(crush->buckets[i]->hash, bl);
::encode(crush->buckets[i]->weight, bl);
::encode(crush->buckets[i]->size, bl);
for (unsigned j=0; j<crush->buckets[i]->size; j++)
::decode(crush->buckets[i]->id, blp);
::decode(crush->buckets[i]->type, blp);
- ::decode(crush->buckets[i]->hash, blp);
::decode(crush->buckets[i]->alg, blp);
+ ::decode(crush->buckets[i]->hash, blp);
::decode(crush->buckets[i]->weight, blp);
::decode(crush->buckets[i]->size, blp);
/* uniform bucket */
struct crush_bucket_uniform *
-crush_make_uniform_bucket(int type, int size,
+crush_make_uniform_bucket(int hash, int type, int size,
int *items,
int item_weight)
{
bucket = malloc(sizeof(*bucket));
memset(bucket, 0, sizeof(*bucket));
bucket->h.alg = CRUSH_BUCKET_UNIFORM;
+ bucket->h.hash = hash;
bucket->h.type = type;
- bucket->h.hash = CRUSH_HASH_RJENKINS1;
bucket->h.size = size;
bucket->h.weight = size * item_weight;
/* list bucket */
struct crush_bucket_list*
-crush_make_list_bucket(int type, int size,
+crush_make_list_bucket(int hash, int type, int size,
int *items,
int *weights)
{
bucket = malloc(sizeof(*bucket));
memset(bucket, 0, sizeof(*bucket));
bucket->h.alg = CRUSH_BUCKET_LIST;
+ bucket->h.hash = hash;
bucket->h.type = type;
- bucket->h.hash = CRUSH_HASH_RJENKINS1;
bucket->h.size = size;
bucket->h.items = malloc(sizeof(__u32)*size);
}
struct crush_bucket_tree*
-crush_make_tree_bucket(int type, int size,
+crush_make_tree_bucket(int hash, int type, int size,
int *items, /* in leaf order */
int *weights)
{
bucket = malloc(sizeof(*bucket));
memset(bucket, 0, sizeof(*bucket));
bucket->h.alg = CRUSH_BUCKET_TREE;
+ bucket->h.hash = hash;
bucket->h.type = type;
- bucket->h.hash = CRUSH_HASH_RJENKINS1;
bucket->h.size = size;
bucket->h.items = malloc(sizeof(__u32)*size);
/* straw bucket */
struct crush_bucket_straw *
-crush_make_straw_bucket(int type,
+crush_make_straw_bucket(int hash,
+ int type,
int size,
int *items,
int *weights)
bucket = malloc(sizeof(*bucket));
memset(bucket, 0, sizeof(*bucket));
bucket->h.alg = CRUSH_BUCKET_STRAW;
+ bucket->h.hash = hash;
bucket->h.type = type;
- bucket->h.hash = CRUSH_HASH_RJENKINS1;
bucket->h.size = size;
bucket->h.items = malloc(sizeof(__u32)*size);
struct crush_bucket*
-crush_make_bucket(int alg, int type, int size,
+crush_make_bucket(int alg, int hash, int type, int size,
int *items,
int *weights)
{
item_weight = weights[0];
else
item_weight = 0;
- return (struct crush_bucket *)crush_make_uniform_bucket(type, size, items, item_weight);
+ return (struct crush_bucket *)crush_make_uniform_bucket(hash, type, size, items, item_weight);
case CRUSH_BUCKET_LIST:
- return (struct crush_bucket *)crush_make_list_bucket(type, size, items, weights);
+ return (struct crush_bucket *)crush_make_list_bucket(hash, type, size, items, weights);
case CRUSH_BUCKET_TREE:
- return (struct crush_bucket *)crush_make_tree_bucket(type, size, items, weights);
+ return (struct crush_bucket *)crush_make_tree_bucket(hash, type, size, items, weights);
case CRUSH_BUCKET_STRAW:
- return (struct crush_bucket *)crush_make_straw_bucket(type, size, items, weights);
+ return (struct crush_bucket *)crush_make_straw_bucket(hash, type, size, items, weights);
}
return 0;
}
extern int crush_add_bucket(struct crush_map *map,
int bucketno,
struct crush_bucket *bucket);
-struct crush_bucket *crush_make_bucket(int alg, int type, int size, int *items, int *weights);
+struct crush_bucket *crush_make_bucket(int alg, int hash, int type, int size, int *items, int *weights);
struct crush_bucket_uniform *
-crush_make_uniform_bucket(int type, int size,
+crush_make_uniform_bucket(int hash, int type, int size,
int *items,
int item_weight);
struct crush_bucket_list*
-crush_make_list_bucket(int type, int size,
+crush_make_list_bucket(int hash, int type, int size,
int *items,
int *weights);
struct crush_bucket_tree*
-crush_make_tree_bucket(int type, int size,
+crush_make_tree_bucket(int hash, int type, int size,
int *items, /* in leaf order */
int *weights);
struct crush_bucket_straw *
-crush_make_straw_bucket(int type, int size,
+crush_make_straw_bucket(int hash, int type, int size,
int *items,
int *weights);
#define CRUSH_HASH_RJENKINS1 0
+#define CRUSH_HASH_DEFAULT CRUSH_HASH_RJENKINS1
+
extern const char *crush_hash_name(int type);
extern __u32 crush_hash32(int type, __u32 a);
int id = 0; // none, yet!
int alg = -1;
+ int hash = -1;
set<int> used_items;
int size = 0;
exit(1);
}
}
+ else if (tag == "hash") {
+ string a = string_node(sub->children[1]);
+ if (a == "rjenkins1")
+ hash = CRUSH_HASH_RJENKINS1;
+ else
+ hash = atoi(a.c_str());
+ }
else if (tag == "item") {
// first, just determine which item pos's are already used
size++;
item_id[name] = id;
item_weight[id] = bucketweight;
- crush.add_bucket(id, alg, type, size, &items[0], &weights[0]);
+ crush.add_bucket(id, alg, hash, type, size, &items[0], &weights[0]);
crush.set_item_name(id, name.c_str());
}
rweights[i] += 0x10000;
}
- crush_bucket *domain = crush_make_bucket(CRUSH_BUCKET_UNIFORM, 1, j, items, weights);
+ crush_bucket *domain = crush_make_bucket(CRUSH_BUCKET_UNIFORM, CRUSH_HASH_DEFAULT, 1, j, items, weights);
ritems[i] = crush_add_bucket(crush.crush, 0, domain);
dout(20) << "added domain bucket i " << ritems[i] << " of size " << j << dendl;
}
// root
- crush_bucket *root = crush_make_bucket(CRUSH_BUCKET_STRAW, 2, ndom, ritems, rweights);
+ crush_bucket *root = crush_make_bucket(CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, 2, ndom, ritems, rweights);
int rootid = crush_add_bucket(crush.crush, 0, root);
crush.set_item_name(rootid, "root");
weights[i] = 0x10000;
}
- crush_bucket *b = crush_make_bucket(CRUSH_BUCKET_STRAW, 1, num_osd, items, weights);
+ crush_bucket *b = crush_make_bucket(CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, 1, num_osd, items, weights);
int rootid = crush_add_bucket(crush.crush, 0, b);
crush.set_item_name(rootid, "root");