Commit 0668216e authored by Sage Weil's avatar Sage Weil

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: default avatarAlex Elder <elder@inktank.com>
Signed-off-by: default avatarSage Weil <sage@inktank.com>
parent a1f4895b
...@@ -519,14 +519,15 @@ int crush_do_rule(const struct crush_map *map, ...@@ -519,14 +519,15 @@ int crush_do_rule(const struct crush_map *map,
} }
for (step = 0; step < rule->len; step++) { for (step = 0; step < rule->len; step++) {
struct crush_rule_step *curstep = &rule->steps[step];
firstn = 0; firstn = 0;
switch (rule->steps[step].op) { switch (curstep->op) {
case CRUSH_RULE_TAKE: case CRUSH_RULE_TAKE:
w[0] = rule->steps[step].arg1; w[0] = curstep->arg1;
/* find position in force_context/hierarchy */ /* find position in force_context/hierarchy */
while (force_pos >= 0 && while (force_pos >= 0 && force_context[force_pos] != w[0])
force_context[force_pos] != w[0])
force_pos--; force_pos--;
/* and move past it */ /* and move past it */
if (force_pos >= 0) if (force_pos >= 0)
...@@ -538,15 +539,16 @@ int crush_do_rule(const struct crush_map *map, ...@@ -538,15 +539,16 @@ int crush_do_rule(const struct crush_map *map,
case CRUSH_RULE_CHOOSE_LEAF_FIRSTN: case CRUSH_RULE_CHOOSE_LEAF_FIRSTN:
case CRUSH_RULE_CHOOSE_FIRSTN: case CRUSH_RULE_CHOOSE_FIRSTN:
firstn = 1; firstn = 1;
/* fall through */
case CRUSH_RULE_CHOOSE_LEAF_INDEP: case CRUSH_RULE_CHOOSE_LEAF_INDEP:
case CRUSH_RULE_CHOOSE_INDEP: case CRUSH_RULE_CHOOSE_INDEP:
if (wsize == 0) if (wsize == 0)
break; break;
recurse_to_leaf = recurse_to_leaf =
rule->steps[step].op == curstep->op ==
CRUSH_RULE_CHOOSE_LEAF_FIRSTN || CRUSH_RULE_CHOOSE_LEAF_FIRSTN ||
rule->steps[step].op == curstep->op ==
CRUSH_RULE_CHOOSE_LEAF_INDEP; CRUSH_RULE_CHOOSE_LEAF_INDEP;
/* reset output */ /* reset output */
...@@ -558,7 +560,7 @@ int crush_do_rule(const struct crush_map *map, ...@@ -558,7 +560,7 @@ int crush_do_rule(const struct crush_map *map,
* basically, numrep <= 0 means relative to * basically, numrep <= 0 means relative to
* the provided result_max * the provided result_max
*/ */
numrep = rule->steps[step].arg1; numrep = curstep->arg1;
if (numrep <= 0) { if (numrep <= 0) {
numrep += result_max; numrep += result_max;
if (numrep <= 0) if (numrep <= 0)
...@@ -569,7 +571,7 @@ int crush_do_rule(const struct crush_map *map, ...@@ -569,7 +571,7 @@ int crush_do_rule(const struct crush_map *map,
/* skip any intermediate types */ /* skip any intermediate types */
while (force_pos && while (force_pos &&
force_context[force_pos] < 0 && force_context[force_pos] < 0 &&
rule->steps[step].arg2 != curstep->arg2 !=
map->buckets[-1 - map->buckets[-1 -
force_context[force_pos]]->type) force_context[force_pos]]->type)
force_pos--; force_pos--;
...@@ -583,7 +585,7 @@ int crush_do_rule(const struct crush_map *map, ...@@ -583,7 +585,7 @@ int crush_do_rule(const struct crush_map *map,
map->buckets[-1-w[i]], map->buckets[-1-w[i]],
weight, weight,
x, numrep, x, numrep,
rule->steps[step].arg2, curstep->arg2,
o+osize, j, o+osize, j,
firstn, firstn,
recurse_to_leaf, c+osize); recurse_to_leaf, c+osize);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment