Skip to content

Commit d390bb2

Browse files
committed
crush: generalize descend_once
The legacy behavior is to make the normal number of tries for the recursive chooseleaf call. The descend_once tunable changed this to making a single try and bail if we get a reject (note that it is impossible to collide in the recursive case). The new set_chooseleaf_tries lets you select the number of recursive chooseleaf attempts for indep mode, or default to 1. Use the same behavior for firstn, except default to total_tries when the legacy tunables are set (for compatibility). This makes the rule step override the (new) default of 1 recursive attempt, keeping behavior consistent with indep mode. Reflects ceph.git commit 685c6950ef3df325ef04ce7c986e36ca2514c5f1. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
1 parent 917edad commit d390bb2

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎net/ceph/crush/mapper.c‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ static int is_out(const struct crush_map *map,
291291
* @out: pointer to output vector
292292
* @outpos: our position in that vector
293293
* @recurse_to_leaf: true if we want one device under each item of given type
294-
* @descend_once: true if we should only try one descent before giving up
295294
* @out2: second output vector for leaf items (if @recurse_to_leaf)
296295
*/
297296
static int crush_choose_firstn(const struct crush_map *map,
@@ -302,7 +301,7 @@ static int crush_choose_firstn(const struct crush_map *map,
302301
unsigned int attempts,
303302
unsigned int recurse_attempts,
304303
int recurse_to_leaf,
305-
int descend_once, int *out2)
304+
int *out2)
306305
{
307306
int rep;
308307
unsigned int ftotal, flocal;
@@ -389,7 +388,6 @@ static int crush_choose_firstn(const struct crush_map *map,
389388
out2, outpos,
390389
recurse_attempts, 0,
391390
0,
392-
map->chooseleaf_descend_once,
393391
NULL) <= outpos)
394392
/* didn't get leaf */
395393
reject = 1;
@@ -414,10 +412,7 @@ static int crush_choose_firstn(const struct crush_map *map,
414412
ftotal++;
415413
flocal++;
416414

417-
if (reject && descend_once)
418-
/* let outer call try again */
419-
skip_rep = 1;
420-
else if (collide && flocal <= map->choose_local_tries)
415+
if (collide && flocal <= map->choose_local_tries)
421416
/* retry locally a few times */
422417
retry_bucket = 1;
423418
else if (map->choose_local_fallback_tries > 0 &&
@@ -639,7 +634,6 @@ int crush_do_rule(const struct crush_map *map,
639634
int numrep;
640635
int choose_tries = map->choose_total_tries;
641636
int choose_leaf_tries = 0;
642-
const int descend_once = 0;
643637

644638
if ((__u32)ruleno >= map->max_rules) {
645639
dprintk(" bad ruleno %d\n", ruleno);
@@ -703,6 +697,14 @@ int crush_do_rule(const struct crush_map *map,
703697
}
704698
j = 0;
705699
if (firstn) {
700+
int recurse_tries;
701+
if (choose_leaf_tries)
702+
recurse_tries =
703+
choose_leaf_tries;
704+
else if (map->chooseleaf_descend_once)
705+
recurse_tries = 1;
706+
else
707+
recurse_tries = choose_tries;
706708
osize += crush_choose_firstn(
707709
map,
708710
map->buckets[-1-w[i]],
@@ -711,9 +713,9 @@ int crush_do_rule(const struct crush_map *map,
711713
curstep->arg2,
712714
o+osize, j,
713715
choose_tries,
714-
choose_leaf_tries ? choose_leaf_tries : choose_tries,
716+
recurse_tries,
715717
recurse_to_leaf,
716-
descend_once, c+osize);
718+
c+osize);
717719
} else {
718720
crush_choose_indep(
719721
map,
@@ -723,7 +725,8 @@ int crush_do_rule(const struct crush_map *map,
723725
curstep->arg2,
724726
o+osize, j,
725727
choose_tries,
726-
choose_leaf_tries ? choose_leaf_tries : 1,
728+
choose_leaf_tries ?
729+
choose_leaf_tries : 1,
727730
recurse_to_leaf,
728731
c+osize,
729732
0);

0 commit comments

Comments
 (0)