crush: clarify numrep vs endpos
Pass numrep (the width of the result) separately from the number of results we want *this* iteration. This makes things less awkward when we do a recursive call (for chooseleaf) and want only one item. Reflects ceph.git commit 1b567ee08972f268c11b43fc881e57b5984dd08b. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
9fe0718282
commit
ab4ce2b5bd
1 changed files with 8 additions and 8 deletions
|
@ -457,13 +457,13 @@ reject:
|
||||||
static void crush_choose_indep(const struct crush_map *map,
|
static void crush_choose_indep(const struct crush_map *map,
|
||||||
struct crush_bucket *bucket,
|
struct crush_bucket *bucket,
|
||||||
const __u32 *weight, int weight_max,
|
const __u32 *weight, int weight_max,
|
||||||
int x, int numrep, int type,
|
int x, int left, int numrep, int type,
|
||||||
int *out, int outpos,
|
int *out, int outpos,
|
||||||
int recurse_to_leaf,
|
int recurse_to_leaf,
|
||||||
int *out2)
|
int *out2)
|
||||||
{
|
{
|
||||||
struct crush_bucket *in = bucket;
|
struct crush_bucket *in = bucket;
|
||||||
int left = numrep - outpos;
|
int endpos = outpos + left;
|
||||||
int rep;
|
int rep;
|
||||||
unsigned int ftotal;
|
unsigned int ftotal;
|
||||||
int r;
|
int r;
|
||||||
|
@ -476,14 +476,14 @@ static void crush_choose_indep(const struct crush_map *map,
|
||||||
bucket->id, x, outpos, numrep);
|
bucket->id, x, outpos, numrep);
|
||||||
|
|
||||||
/* initially my result is undefined */
|
/* initially my result is undefined */
|
||||||
for (rep = outpos; rep < numrep; rep++) {
|
for (rep = outpos; rep < endpos; rep++) {
|
||||||
out[rep] = CRUSH_ITEM_UNDEF;
|
out[rep] = CRUSH_ITEM_UNDEF;
|
||||||
if (out2)
|
if (out2)
|
||||||
out2[rep] = CRUSH_ITEM_UNDEF;
|
out2[rep] = CRUSH_ITEM_UNDEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) {
|
for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) {
|
||||||
for (rep = outpos; rep < numrep; rep++) {
|
for (rep = outpos; rep < endpos; rep++) {
|
||||||
if (out[rep] != CRUSH_ITEM_UNDEF)
|
if (out[rep] != CRUSH_ITEM_UNDEF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ static void crush_choose_indep(const struct crush_map *map,
|
||||||
|
|
||||||
/* collision? */
|
/* collision? */
|
||||||
collide = 0;
|
collide = 0;
|
||||||
for (i = outpos; i < numrep; i++) {
|
for (i = outpos; i < endpos; i++) {
|
||||||
if (out[i] == item) {
|
if (out[i] == item) {
|
||||||
collide = 1;
|
collide = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -565,7 +565,7 @@ static void crush_choose_indep(const struct crush_map *map,
|
||||||
crush_choose_indep(map,
|
crush_choose_indep(map,
|
||||||
map->buckets[-1-item],
|
map->buckets[-1-item],
|
||||||
weight, weight_max,
|
weight, weight_max,
|
||||||
x, rep+1, 0,
|
x, 1, numrep, 0,
|
||||||
out2, rep,
|
out2, rep,
|
||||||
0, NULL);
|
0, NULL);
|
||||||
if (out2[rep] == CRUSH_ITEM_NONE) {
|
if (out2[rep] == CRUSH_ITEM_NONE) {
|
||||||
|
@ -590,7 +590,7 @@ static void crush_choose_indep(const struct crush_map *map,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (rep = outpos; rep < numrep; rep++) {
|
for (rep = outpos; rep < endpos; rep++) {
|
||||||
if (out[rep] == CRUSH_ITEM_UNDEF) {
|
if (out[rep] == CRUSH_ITEM_UNDEF) {
|
||||||
out[rep] = CRUSH_ITEM_NONE;
|
out[rep] = CRUSH_ITEM_NONE;
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ int crush_do_rule(const struct crush_map *map,
|
||||||
map,
|
map,
|
||||||
map->buckets[-1-w[i]],
|
map->buckets[-1-w[i]],
|
||||||
weight, weight_max,
|
weight, weight_max,
|
||||||
x, numrep,
|
x, numrep, numrep,
|
||||||
curstep->arg2,
|
curstep->arg2,
|
||||||
o+osize, j,
|
o+osize, j,
|
||||||
recurse_to_leaf,
|
recurse_to_leaf,
|
||||||
|
|
Loading…
Add table
Reference in a new issue