ceph: fix crush CHOOSE_LEAF when type is already a leaf
We may not recurse for CHOOSE_LEAF if we start with a leaf node. When that happens, the out2 vector needs to be filled in with the result. Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
parent
55bda7aacd
commit
a1a31e7342
1 changed files with 25 additions and 13 deletions
|
@ -238,7 +238,7 @@ static int bucket_straw_choose(struct crush_bucket_straw *bucket,
|
||||||
|
|
||||||
static int crush_bucket_choose(struct crush_bucket *in, int x, int r)
|
static int crush_bucket_choose(struct crush_bucket *in, int x, int r)
|
||||||
{
|
{
|
||||||
dprintk("choose %d x=%d r=%d\n", in->id, x, r);
|
dprintk(" crush_bucket_choose %d x=%d r=%d\n", in->id, x, r);
|
||||||
switch (in->alg) {
|
switch (in->alg) {
|
||||||
case CRUSH_BUCKET_UNIFORM:
|
case CRUSH_BUCKET_UNIFORM:
|
||||||
return bucket_uniform_choose((struct crush_bucket_uniform *)in,
|
return bucket_uniform_choose((struct crush_bucket_uniform *)in,
|
||||||
|
@ -305,7 +305,9 @@ static int crush_choose(struct crush_map *map,
|
||||||
int itemtype;
|
int itemtype;
|
||||||
int collide, reject;
|
int collide, reject;
|
||||||
const int orig_tries = 5; /* attempts before we fall back to search */
|
const int orig_tries = 5; /* attempts before we fall back to search */
|
||||||
dprintk("choose bucket %d x %d outpos %d\n", bucket->id, x, outpos);
|
|
||||||
|
dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d\n", recurse_to_leaf ? "_LEAF" : "",
|
||||||
|
bucket->id, x, outpos, numrep);
|
||||||
|
|
||||||
for (rep = outpos; rep < numrep; rep++) {
|
for (rep = outpos; rep < numrep; rep++) {
|
||||||
/* keep trying until we get a non-out, non-colliding item */
|
/* keep trying until we get a non-out, non-colliding item */
|
||||||
|
@ -378,15 +380,25 @@ static int crush_choose(struct crush_map *map,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recurse_to_leaf &&
|
reject = 0;
|
||||||
item < 0 &&
|
if (recurse_to_leaf) {
|
||||||
crush_choose(map, map->buckets[-1-item],
|
if (item < 0) {
|
||||||
weight,
|
if (crush_choose(map,
|
||||||
x, outpos+1, 0,
|
map->buckets[-1-item],
|
||||||
out2, outpos,
|
weight,
|
||||||
firstn, 0, NULL) <= outpos) {
|
x, outpos+1, 0,
|
||||||
reject = 1;
|
out2, outpos,
|
||||||
} else {
|
firstn, 0,
|
||||||
|
NULL) <= outpos)
|
||||||
|
/* didn't get leaf */
|
||||||
|
reject = 1;
|
||||||
|
} else {
|
||||||
|
/* we already have a leaf! */
|
||||||
|
out2[outpos] = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!reject) {
|
||||||
/* out? */
|
/* out? */
|
||||||
if (itemtype == 0)
|
if (itemtype == 0)
|
||||||
reject = is_out(map, weight,
|
reject = is_out(map, weight,
|
||||||
|
@ -425,12 +437,12 @@ static int crush_choose(struct crush_map *map,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintk("choose got %d\n", item);
|
dprintk("CHOOSE got %d\n", item);
|
||||||
out[outpos] = item;
|
out[outpos] = item;
|
||||||
outpos++;
|
outpos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintk("choose returns %d\n", outpos);
|
dprintk("CHOOSE returns %d\n", outpos);
|
||||||
return outpos;
|
return outpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue