]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/mapper: new SET_CHOOSE_LEAF_TRIES command
authorSage Weil <sage@inktank.com>
Tue, 3 Dec 2013 16:16:41 +0000 (08:16 -0800)
committerSage Weil <sage@inktank.com>
Tue, 3 Dec 2013 22:41:25 +0000 (14:41 -0800)
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!)

Signed-off-by: Sage Weil <sage@inktank.com>
src/crush/crush.h
src/crush/mapper.c

index 95fb7e92ed7dc10a764690c52c827da2c63aa503..bcc2cfe680b89be915c7be34500595edd1743c62 100644 (file)
@@ -55,6 +55,8 @@ enum {
        CRUSH_RULE_EMIT = 4,          /* no args */
        CRUSH_RULE_CHOOSE_LEAF_FIRSTN = 6,
        CRUSH_RULE_CHOOSE_LEAF_INDEP = 7,
+
+       CRUSH_RULE_SET_CHOOSE_LEAF_TRIES = 9,
 };
 
 /*
index 0aa07b742e5385458fbbc2a580ec00c5802e0cd2..50516e19705c84b203f52e62f5df0be91a23c7e2 100644 (file)
@@ -454,11 +454,12 @@ reject:
  *
  */
 static void crush_choose_indep(const struct crush_map *map,
-                             struct crush_bucket *bucket,
-                             const __u32 *weight, int weight_max,
-                             int *out, int outpos,
-                             int recurse_to_leaf,
+                              struct crush_bucket *bucket,
+                              const __u32 *weight, int weight_max,
                               int x, int left, int numrep, int type,
+                              int *out, int outpos,
+                              unsigned attempts, unsigned recurse_attempts,
+                              int recurse_to_leaf,
                               int *out2,
                               int parent_r)
 {
@@ -482,7 +483,7 @@ static void crush_choose_indep(const struct crush_map *map,
                        out2[rep] = CRUSH_ITEM_UNDEF;
        }
 
-       for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) {
+       for (ftotal = 0; left > 0 && ftotal < attempts; ftotal++) {
                for (rep = outpos; rep < endpos; rep++) {
                        if (out[rep] != CRUSH_ITEM_UNDEF)
                                continue;
@@ -563,10 +564,11 @@ static void crush_choose_indep(const struct crush_map *map,
                                if (recurse_to_leaf) {
                                        if (item < 0) {
                                                crush_choose_indep(map,
-                                                                  map->buckets[-1-item],
-                                                                  weight, weight_max,
-                                                                  out2, rep,
+                                                  map->buckets[-1-item],
+                                                  weight, weight_max,
                                                   x, 1, numrep, 0,
+                                                  out2, rep,
+                                                  recurse_attempts, 0,
                                                   0, NULL, r);
                                                if (out2[rep] == CRUSH_ITEM_NONE) {
                                                        /* placed nothing; no leaf */
@@ -627,6 +629,7 @@ int crush_do_rule(const struct crush_map *map,
        __u32 step;
        int i, j;
        int numrep;
+       int choose_leaf_tries = 1;
        const int descend_once = 0;
 
        if ((__u32)ruleno >= map->max_rules) {
@@ -649,6 +652,11 @@ int crush_do_rule(const struct crush_map *map,
                        wsize = 1;
                        break;
 
+               case CRUSH_RULE_SET_CHOOSE_LEAF_TRIES:
+                       if (curstep->arg1 > 0)
+                               choose_leaf_tries = curstep->arg1;
+                       break;
+
                case CRUSH_RULE_CHOOSE_LEAF_FIRSTN:
                case CRUSH_RULE_CHOOSE_FIRSTN:
                        firstn = 1;
@@ -698,6 +706,8 @@ int crush_do_rule(const struct crush_map *map,
                                                x, numrep, numrep,
                                                curstep->arg2,
                                                o+osize, j,
+                                               map->choose_total_tries,
+                                               choose_leaf_tries,
                                                recurse_to_leaf,
                                                c+osize,
                                                0);