aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2013-12-24 14:19:25 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2013-12-31 13:32:19 -0500
commitab4ce2b5bdb5ca416756df3df6f5c63667a05065 (patch)
tree416fb514da8cd03f0700bcb14bbf1b6e6ecaf11a
parent9fe07182827d9913daf85f3e6a950578a3fd4c5d (diff)
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>
-rw-r--r--net/ceph/crush/mapper.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index a71f8c4c78ec..125dbd04f2b6 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -457,13 +457,13 @@ reject:
457static void crush_choose_indep(const struct crush_map *map, 457static void crush_choose_indep(const struct crush_map *map,
458 struct crush_bucket *bucket, 458 struct crush_bucket *bucket,
459 const __u32 *weight, int weight_max, 459 const __u32 *weight, int weight_max,
460 int x, int numrep, int type, 460 int x, int left, int numrep, int type,
461 int *out, int outpos, 461 int *out, int outpos,
462 int recurse_to_leaf, 462 int recurse_to_leaf,
463 int *out2) 463 int *out2)
464{ 464{
465 struct crush_bucket *in = bucket; 465 struct crush_bucket *in = bucket;
466 int left = numrep - outpos; 466 int endpos = outpos + left;
467 int rep; 467 int rep;
468 unsigned int ftotal; 468 unsigned int ftotal;
469 int r; 469 int r;
@@ -476,14 +476,14 @@ static void crush_choose_indep(const struct crush_map *map,
476 bucket->id, x, outpos, numrep); 476 bucket->id, x, outpos, numrep);
477 477
478 /* initially my result is undefined */ 478 /* initially my result is undefined */
479 for (rep = outpos; rep < numrep; rep++) { 479 for (rep = outpos; rep < endpos; rep++) {
480 out[rep] = CRUSH_ITEM_UNDEF; 480 out[rep] = CRUSH_ITEM_UNDEF;
481 if (out2) 481 if (out2)
482 out2[rep] = CRUSH_ITEM_UNDEF; 482 out2[rep] = CRUSH_ITEM_UNDEF;
483 } 483 }
484 484
485 for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) { 485 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++) {
487 if (out[rep] != CRUSH_ITEM_UNDEF) 487 if (out[rep] != CRUSH_ITEM_UNDEF)
488 continue; 488 continue;
489 489
@@ -551,7 +551,7 @@ static void crush_choose_indep(const struct crush_map *map,
551 551
552 /* collision? */ 552 /* collision? */
553 collide = 0; 553 collide = 0;
554 for (i = outpos; i < numrep; i++) { 554 for (i = outpos; i < endpos; i++) {
555 if (out[i] == item) { 555 if (out[i] == item) {
556 collide = 1; 556 collide = 1;
557 break; 557 break;
@@ -565,7 +565,7 @@ static void crush_choose_indep(const struct crush_map *map,
565 crush_choose_indep(map, 565 crush_choose_indep(map,
566 map->buckets[-1-item], 566 map->buckets[-1-item],
567 weight, weight_max, 567 weight, weight_max,
568 x, rep+1, 0, 568 x, 1, numrep, 0,
569 out2, rep, 569 out2, rep,
570 0, NULL); 570 0, NULL);
571 if (out2[rep] == CRUSH_ITEM_NONE) { 571 if (out2[rep] == CRUSH_ITEM_NONE) {
@@ -590,7 +590,7 @@ static void crush_choose_indep(const struct crush_map *map,
590 } 590 }
591 } 591 }
592 } 592 }
593 for (rep = outpos; rep < numrep; rep++) { 593 for (rep = outpos; rep < endpos; rep++) {
594 if (out[rep] == CRUSH_ITEM_UNDEF) { 594 if (out[rep] == CRUSH_ITEM_UNDEF) {
595 out[rep] = CRUSH_ITEM_NONE; 595 out[rep] = CRUSH_ITEM_NONE;
596 } 596 }
@@ -698,7 +698,7 @@ int crush_do_rule(const struct crush_map *map,
698 map, 698 map,
699 map->buckets[-1-w[i]], 699 map->buckets[-1-w[i]],
700 weight, weight_max, 700 weight, weight_max,
701 x, numrep, 701 x, numrep, numrep,
702 curstep->arg2, 702 curstep->arg2,
703 o+osize, j, 703 o+osize, j,
704 recurse_to_leaf, 704 recurse_to_leaf,