aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-05-07 18:35:48 -0400
committerSage Weil <sage@inktank.com>2012-05-07 18:38:51 -0400
commit0668216efe16ab1adf077e5f138775cee2af927a (patch)
tree9839f651cb90f22e50ddc585098105e8028497e0
parenta1f4895be8bf1ba56c2306b058f51619e9b0e8f8 (diff)
crush: use a temporary variable to simplify crush_do_rule
Use a temporary variable here to avoid repeated array lookups and clean up the code a bit. This reflects ceph.git commit 6b5be27634ad307b471a5bf0db85c4f5c834885f. Reviewed-by: Alex Elder <elder@inktank.com> Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--net/ceph/crush/mapper.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index 00baad5d3bd..fba9460fe57 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -519,14 +519,15 @@ int crush_do_rule(const struct crush_map *map,
519 } 519 }
520 520
521 for (step = 0; step < rule->len; step++) { 521 for (step = 0; step < rule->len; step++) {
522 struct crush_rule_step *curstep = &rule->steps[step];
523
522 firstn = 0; 524 firstn = 0;
523 switch (rule->steps[step].op) { 525 switch (curstep->op) {
524 case CRUSH_RULE_TAKE: 526 case CRUSH_RULE_TAKE:
525 w[0] = rule->steps[step].arg1; 527 w[0] = curstep->arg1;
526 528
527 /* find position in force_context/hierarchy */ 529 /* find position in force_context/hierarchy */
528 while (force_pos >= 0 && 530 while (force_pos >= 0 && force_context[force_pos] != w[0])
529 force_context[force_pos] != w[0])
530 force_pos--; 531 force_pos--;
531 /* and move past it */ 532 /* and move past it */
532 if (force_pos >= 0) 533 if (force_pos >= 0)
@@ -538,15 +539,16 @@ int crush_do_rule(const struct crush_map *map,
538 case CRUSH_RULE_CHOOSE_LEAF_FIRSTN: 539 case CRUSH_RULE_CHOOSE_LEAF_FIRSTN:
539 case CRUSH_RULE_CHOOSE_FIRSTN: 540 case CRUSH_RULE_CHOOSE_FIRSTN:
540 firstn = 1; 541 firstn = 1;
542 /* fall through */
541 case CRUSH_RULE_CHOOSE_LEAF_INDEP: 543 case CRUSH_RULE_CHOOSE_LEAF_INDEP:
542 case CRUSH_RULE_CHOOSE_INDEP: 544 case CRUSH_RULE_CHOOSE_INDEP:
543 if (wsize == 0) 545 if (wsize == 0)
544 break; 546 break;
545 547
546 recurse_to_leaf = 548 recurse_to_leaf =
547 rule->steps[step].op == 549 curstep->op ==
548 CRUSH_RULE_CHOOSE_LEAF_FIRSTN || 550 CRUSH_RULE_CHOOSE_LEAF_FIRSTN ||
549 rule->steps[step].op == 551 curstep->op ==
550 CRUSH_RULE_CHOOSE_LEAF_INDEP; 552 CRUSH_RULE_CHOOSE_LEAF_INDEP;
551 553
552 /* reset output */ 554 /* reset output */
@@ -558,7 +560,7 @@ int crush_do_rule(const struct crush_map *map,
558 * basically, numrep <= 0 means relative to 560 * basically, numrep <= 0 means relative to
559 * the provided result_max 561 * the provided result_max
560 */ 562 */
561 numrep = rule->steps[step].arg1; 563 numrep = curstep->arg1;
562 if (numrep <= 0) { 564 if (numrep <= 0) {
563 numrep += result_max; 565 numrep += result_max;
564 if (numrep <= 0) 566 if (numrep <= 0)
@@ -569,7 +571,7 @@ int crush_do_rule(const struct crush_map *map,
569 /* skip any intermediate types */ 571 /* skip any intermediate types */
570 while (force_pos && 572 while (force_pos &&
571 force_context[force_pos] < 0 && 573 force_context[force_pos] < 0 &&
572 rule->steps[step].arg2 != 574 curstep->arg2 !=
573 map->buckets[-1 - 575 map->buckets[-1 -
574 force_context[force_pos]]->type) 576 force_context[force_pos]]->type)
575 force_pos--; 577 force_pos--;
@@ -583,7 +585,7 @@ int crush_do_rule(const struct crush_map *map,
583 map->buckets[-1-w[i]], 585 map->buckets[-1-w[i]],
584 weight, 586 weight,
585 x, numrep, 587 x, numrep,
586 rule->steps[step].arg2, 588 curstep->arg2,
587 o+osize, j, 589 o+osize, j,
588 firstn, 590 firstn,
589 recurse_to_leaf, c+osize); 591 recurse_to_leaf, c+osize);