aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2013-12-24 14:19:26 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2013-12-31 13:32:25 -0500
commitd390bb2a83086f2b79c152e2c1734813bd257d9b (patch)
tree27e07d62f80cb4f65a16b09cffadf71b3f243a6e /net/ceph
parent917edad5d1d62070436b74ecbf5ea019b651ff69 (diff)
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>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/crush/mapper.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index e9256a30e60d..0613dd2d5fa3 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -291,7 +291,6 @@ static int is_out(const struct crush_map *map,
291 * @out: pointer to output vector 291 * @out: pointer to output vector
292 * @outpos: our position in that vector 292 * @outpos: our position in that vector
293 * @recurse_to_leaf: true if we want one device under each item of given type 293 * @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
295 * @out2: second output vector for leaf items (if @recurse_to_leaf) 294 * @out2: second output vector for leaf items (if @recurse_to_leaf)
296 */ 295 */
297static int crush_choose_firstn(const struct crush_map *map, 296static int crush_choose_firstn(const struct crush_map *map,
@@ -302,7 +301,7 @@ static int crush_choose_firstn(const struct crush_map *map,
302 unsigned int attempts, 301 unsigned int attempts,
303 unsigned int recurse_attempts, 302 unsigned int recurse_attempts,
304 int recurse_to_leaf, 303 int recurse_to_leaf,
305 int descend_once, int *out2) 304 int *out2)
306{ 305{
307 int rep; 306 int rep;
308 unsigned int ftotal, flocal; 307 unsigned int ftotal, flocal;
@@ -389,7 +388,6 @@ static int crush_choose_firstn(const struct crush_map *map,
389 out2, outpos, 388 out2, outpos,
390 recurse_attempts, 0, 389 recurse_attempts, 0,
391 0, 390 0,
392 map->chooseleaf_descend_once,
393 NULL) <= outpos) 391 NULL) <= outpos)
394 /* didn't get leaf */ 392 /* didn't get leaf */
395 reject = 1; 393 reject = 1;
@@ -414,10 +412,7 @@ reject:
414 ftotal++; 412 ftotal++;
415 flocal++; 413 flocal++;
416 414
417 if (reject && descend_once) 415 if (collide && flocal <= map->choose_local_tries)
418 /* let outer call try again */
419 skip_rep = 1;
420 else if (collide && flocal <= map->choose_local_tries)
421 /* retry locally a few times */ 416 /* retry locally a few times */
422 retry_bucket = 1; 417 retry_bucket = 1;
423 else if (map->choose_local_fallback_tries > 0 && 418 else if (map->choose_local_fallback_tries > 0 &&
@@ -639,7 +634,6 @@ int crush_do_rule(const struct crush_map *map,
639 int numrep; 634 int numrep;
640 int choose_tries = map->choose_total_tries; 635 int choose_tries = map->choose_total_tries;
641 int choose_leaf_tries = 0; 636 int choose_leaf_tries = 0;
642 const int descend_once = 0;
643 637
644 if ((__u32)ruleno >= map->max_rules) { 638 if ((__u32)ruleno >= map->max_rules) {
645 dprintk(" bad ruleno %d\n", ruleno); 639 dprintk(" bad ruleno %d\n", ruleno);
@@ -703,6 +697,14 @@ int crush_do_rule(const struct crush_map *map,
703 } 697 }
704 j = 0; 698 j = 0;
705 if (firstn) { 699 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;
706 osize += crush_choose_firstn( 708 osize += crush_choose_firstn(
707 map, 709 map,
708 map->buckets[-1-w[i]], 710 map->buckets[-1-w[i]],
@@ -711,9 +713,9 @@ int crush_do_rule(const struct crush_map *map,
711 curstep->arg2, 713 curstep->arg2,
712 o+osize, j, 714 o+osize, j,
713 choose_tries, 715 choose_tries,
714 choose_leaf_tries ? choose_leaf_tries : choose_tries, 716 recurse_tries,
715 recurse_to_leaf, 717 recurse_to_leaf,
716 descend_once, c+osize); 718 c+osize);
717 } else { 719 } else {
718 crush_choose_indep( 720 crush_choose_indep(
719 map, 721 map,
@@ -723,7 +725,8 @@ int crush_do_rule(const struct crush_map *map,
723 curstep->arg2, 725 curstep->arg2,
724 o+osize, j, 726 o+osize, j,
725 choose_tries, 727 choose_tries,
726 choose_leaf_tries ? choose_leaf_tries : 1, 728 choose_leaf_tries ?
729 choose_leaf_tries : 1,
727 recurse_to_leaf, 730 recurse_to_leaf,
728 c+osize, 731 c+osize,
729 0); 732 0);