Skip to content

Commit ab4ce2b

Browse files
committed
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>
1 parent 9fe0718 commit ab4ce2b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎net/ceph/crush/mapper.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,13 @@ static int crush_choose_firstn(const struct crush_map *map,
457457
static void crush_choose_indep(const struct crush_map *map,
458458
struct crush_bucket *bucket,
459459
const __u32 *weight, int weight_max,
460-
int x, int numrep, int type,
460+
int x, int left, int numrep, int type,
461461
int *out, int outpos,
462462
int recurse_to_leaf,
463463
int *out2)
464464
{
465465
struct crush_bucket *in = bucket;
466-
int left = numrep - outpos;
466+
int endpos = outpos + left;
467467
int rep;
468468
unsigned int ftotal;
469469
int r;
@@ -476,14 +476,14 @@ static void crush_choose_indep(const struct crush_map *map,
476476
bucket->id, x, outpos, numrep);
477477

478478
/* initially my result is undefined */
479-
for (rep = outpos; rep < numrep; rep++) {
479+
for (rep = outpos; rep < endpos; rep++) {
480480
out[rep] = CRUSH_ITEM_UNDEF;
481481
if (out2)
482482
out2[rep] = CRUSH_ITEM_UNDEF;
483483
}
484484

485485
for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) {
486-
for (rep = outpos; rep < numrep; rep++) {
486+
for (rep = outpos; rep < endpos; rep++) {
487487
if (out[rep] != CRUSH_ITEM_UNDEF)
488488
continue;
489489

@@ -551,7 +551,7 @@ static void crush_choose_indep(const struct crush_map *map,
551551

552552
/* collision? */
553553
collide = 0;
554-
for (i = outpos; i < numrep; i++) {
554+
for (i = outpos; i < endpos; i++) {
555555
if (out[i] == item) {
556556
collide = 1;
557557
break;
@@ -565,7 +565,7 @@ static void crush_choose_indep(const struct crush_map *map,
565565
crush_choose_indep(map,
566566
map->buckets[-1-item],
567567
weight, weight_max,
568-
x, rep+1, 0,
568+
x, 1, numrep, 0,
569569
out2, rep,
570570
0, NULL);
571571
if (out2[rep] == CRUSH_ITEM_NONE) {
@@ -590,7 +590,7 @@ static void crush_choose_indep(const struct crush_map *map,
590590
}
591591
}
592592
}
593-
for (rep = outpos; rep < numrep; rep++) {
593+
for (rep = outpos; rep < endpos; rep++) {
594594
if (out[rep] == CRUSH_ITEM_UNDEF) {
595595
out[rep] = CRUSH_ITEM_NONE;
596596
}
@@ -698,7 +698,7 @@ int crush_do_rule(const struct crush_map *map,
698698
map,
699699
map->buckets[-1-w[i]],
700700
weight, weight_max,
701-
x, numrep,
701+
x, numrep, numrep,
702702
curstep->arg2,
703703
o+osize, j,
704704
recurse_to_leaf,

0 commit comments

Comments
 (0)