Skip to content

Commit be3226a

Browse files
committed
crush: new SET_CHOOSE_LEAF_TRIES command
Explicitly control the number of sample attempts, and allow the number of tries in the recursive call to be explicitly controlled via the rule. This is important because the amount of time we want to spend looking for a solution may be rule dependent (e.g., higher for the wide indep pool than the rep pools). (We should do the same for the other tunables, by the way!) Reflects ceph.git commit c43c893be872f709c787bc57f46c0e97876ff681. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
1 parent 4158608 commit be3226a

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

‎include/linux/crush/crush.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ enum {
4646
CRUSH_RULE_EMIT = 4, /* no args */
4747
CRUSH_RULE_CHOOSE_LEAF_FIRSTN = 6,
4848
CRUSH_RULE_CHOOSE_LEAF_INDEP = 7,
49+
50+
CRUSH_RULE_SET_CHOOSE_LEAF_TRIES = 9,
4951
};
5052

5153
/*

‎net/ceph/crush/mapper.c‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,13 @@ static int crush_choose_firstn(const struct crush_map *map,
455455
*
456456
*/
457457
static void crush_choose_indep(const struct crush_map *map,
458-
struct crush_bucket *bucket,
459-
const __u32 *weight, int weight_max,
458+
struct crush_bucket *bucket,
459+
const __u32 *weight, int weight_max,
460460
int x, int left, int numrep, int type,
461-
int *out, int outpos,
462-
int recurse_to_leaf,
461+
int *out, int outpos,
462+
unsigned int attempts,
463+
unsigned int recurse_attempts,
464+
int recurse_to_leaf,
463465
int *out2,
464466
int parent_r)
465467
{
@@ -483,7 +485,7 @@ static void crush_choose_indep(const struct crush_map *map,
483485
out2[rep] = CRUSH_ITEM_UNDEF;
484486
}
485487

486-
for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) {
488+
for (ftotal = 0; left > 0 && ftotal < attempts; ftotal++) {
487489
for (rep = outpos; rep < endpos; rep++) {
488490
if (out[rep] != CRUSH_ITEM_UNDEF)
489491
continue;
@@ -564,11 +566,12 @@ static void crush_choose_indep(const struct crush_map *map,
564566
if (recurse_to_leaf) {
565567
if (item < 0) {
566568
crush_choose_indep(map,
567-
map->buckets[-1-item],
568-
weight, weight_max,
569-
x, 1, numrep, 0,
570-
out2, rep,
571-
0, NULL, r);
569+
map->buckets[-1-item],
570+
weight, weight_max,
571+
x, 1, numrep, 0,
572+
out2, rep,
573+
recurse_attempts, 0,
574+
0, NULL, r);
572575
if (out2[rep] == CRUSH_ITEM_NONE) {
573576
/* placed nothing; no leaf */
574577
break;
@@ -631,6 +634,7 @@ int crush_do_rule(const struct crush_map *map,
631634
__u32 step;
632635
int i, j;
633636
int numrep;
637+
int choose_leaf_tries = 1;
634638
const int descend_once = 0;
635639

636640
if ((__u32)ruleno >= map->max_rules) {
@@ -653,6 +657,11 @@ int crush_do_rule(const struct crush_map *map,
653657
wsize = 1;
654658
break;
655659

660+
case CRUSH_RULE_SET_CHOOSE_LEAF_TRIES:
661+
if (curstep->arg1 > 0)
662+
choose_leaf_tries = curstep->arg1;
663+
break;
664+
656665
case CRUSH_RULE_CHOOSE_LEAF_FIRSTN:
657666
case CRUSH_RULE_CHOOSE_FIRSTN:
658667
firstn = 1;
@@ -702,6 +711,8 @@ int crush_do_rule(const struct crush_map *map,
702711
x, numrep, numrep,
703712
curstep->arg2,
704713
o+osize, j,
714+
map->choose_total_tries,
715+
choose_leaf_tries,
705716
recurse_to_leaf,
706717
c+osize,
707718
0);

0 commit comments

Comments
 (0)