]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/mapper: apply chooseleaf_tries to firstn mode too
authorSage Weil <sage@inktank.com>
Tue, 3 Dec 2013 16:33:55 +0000 (08:33 -0800)
committerSage Weil <sage@inktank.com>
Fri, 6 Dec 2013 22:24:02 +0000 (14:24 -0800)
Parameterize the attempts for the _firstn choose method, and apply the
rule-specified tries count to firstn mode as well.  Note that we have
slightly different behavior here than with indep:

 If the firstn value is not specified for firstn, we pass through the
 normal attempt count.  This maintains compatibility with legacy behavior.
 Note that this is usually *not* actually N^2 work, though, because of the
 descend_once tunable.  However, descend_once is unfortunately *not* the
 same thing as 1 chooseleaf try because it is only checked on a reject but
 not on a collision.  Sigh.

 In contrast, for indep, if tries is not specified we default to 1
 recursive attempt, because that is simply more sane, and we have the
 option to do so.  The descend_once tunable has no effect for indep.

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

index bcc2cfe680b89be915c7be34500595edd1743c62..2f3812ca68bb30d40ba6e84f1f50506407259b86 100644 (file)
@@ -174,7 +174,10 @@ struct crush_map {
        __u32 choose_local_fallback_tries;
        /* choose attempts before giving up */ 
        __u32 choose_total_tries;
-       /* attempt chooseleaf inner descent once; on failure retry outer descent */
+       /* attempt chooseleaf inner descent once for firstn mode; on
+        * reject retry outer descent.  Note that this does *not*
+        * apply to a collision: in that case we will retry as we used
+        * to. */
        __u32 chooseleaf_descend_once;
 
        __u32 *choose_tries;
index 50516e19705c84b203f52e62f5df0be91a23c7e2..9110cc52df10b0a86595e49165a03b0307cd6a20 100644 (file)
@@ -296,6 +296,7 @@ static int crush_choose_firstn(const struct crush_map *map,
                               const __u32 *weight, int weight_max,
                               int x, int numrep, int type,
                               int *out, int outpos,
+                              unsigned attempts, unsigned recurse_attempts,
                               int recurse_to_leaf,
                               int descend_once, int *out2)
 {
@@ -382,6 +383,7 @@ static int crush_choose_firstn(const struct crush_map *map,
                                                         weight, weight_max,
                                                         x, outpos+1, 0,
                                                         out2, outpos,
+                                                        recurse_attempts, 0,
                                                         0,
                                                         map->chooseleaf_descend_once,
                                                         NULL) <= outpos)
@@ -417,7 +419,7 @@ reject:
                                                 flocal <= in->size + map->choose_local_fallback_tries)
                                                /* exhaustive bucket search */
                                                retry_bucket = 1;
-                                       else if (ftotal <= map->choose_total_tries)
+                                       else if (ftotal <= attempts)
                                                /* then retry descent */
                                                retry_descent = 1;
                                        else
@@ -629,7 +631,8 @@ int crush_do_rule(const struct crush_map *map,
        __u32 step;
        int i, j;
        int numrep;
-       int choose_leaf_tries = 1;
+       int choose_tries = map->choose_total_tries;
+       int choose_leaf_tries = 0;
        const int descend_once = 0;
 
        if ((__u32)ruleno >= map->max_rules) {
@@ -696,6 +699,8 @@ int crush_do_rule(const struct crush_map *map,
                                                x, numrep,
                                                curstep->arg2,
                                                o+osize, j,
+                                               choose_tries,
+                                               choose_leaf_tries ? choose_leaf_tries : choose_tries,
                                                recurse_to_leaf,
                                                descend_once, c+osize);
                                } else {
@@ -706,8 +711,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,
+                                               choose_tries,
+                                               choose_leaf_tries ? choose_leaf_tries : 1,
                                                recurse_to_leaf,
                                                c+osize,
                                                0);