]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/mapper: generalize descend_once
authorSage Weil <sage@inktank.com>
Tue, 17 Dec 2013 05:33:07 +0000 (21:33 -0800)
committerSage Weil <sage@inktank.com>
Tue, 17 Dec 2013 05:33:07 +0000 (21:33 -0800)
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.

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

index 0c21ddddbd75d7bb4a9d98984f504b4ccad19ba9..cbd92cb620a01a3e016aafe0d452f6cb5181562f 100644 (file)
@@ -289,7 +289,6 @@ static int is_out(const struct crush_map *map, const __u32 *weight, int weight_m
  * @param out pointer to output vector
  * @param outpos our position in that vector
  * @param recurse_to_leaf: true if we want one device under each item of given type
- * @descend_once: true if we should only try one descent before giving up
  * @param out2 second output vector for leaf items (if @a recurse_to_leaf)
  */
 static int crush_choose_firstn(const struct crush_map *map,
@@ -299,7 +298,7 @@ static int crush_choose_firstn(const struct crush_map *map,
                               int *out, int outpos,
                               unsigned attempts, unsigned recurse_attempts,
                               int recurse_to_leaf,
-                              int descend_once, int *out2)
+                              int *out2)
 {
        int rep;
        unsigned int ftotal, flocal;
@@ -386,7 +385,6 @@ static int crush_choose_firstn(const struct crush_map *map,
                                                         out2, outpos,
                                                         recurse_attempts, 0,
                                                         0,
-                                                        map->chooseleaf_descend_once,
                                                         NULL) <= outpos)
                                                        /* didn't get leaf */
                                                        reject = 1;
@@ -410,10 +408,7 @@ reject:
                                        ftotal++;
                                        flocal++;
 
-                                       if (reject && descend_once)
-                                               /* let outer call try again */
-                                               skip_rep = 1;
-                                       else if (collide && flocal <= map->choose_local_tries)
+                                       if (collide && flocal <= map->choose_local_tries)
                                                /* retry locally a few times */
                                                retry_bucket = 1;
                                        else if (map->choose_local_fallback_tries > 0 &&
@@ -662,7 +657,6 @@ int crush_do_rule(const struct crush_map *map,
        int numrep;
        int choose_tries = map->choose_total_tries;
        int choose_leaf_tries = 0;
-       const int descend_once = 0;
 
        if ((__u32)ruleno >= map->max_rules) {
                dprintk(" bad ruleno %d\n", ruleno);
@@ -726,6 +720,14 @@ int crush_do_rule(const struct crush_map *map,
                                }
                                j = 0;
                                if (firstn) {
+                                       int recurse_tries;
+                                       if (choose_leaf_tries)
+                                               recurse_tries =
+                                                       choose_leaf_tries;
+                                       else if (map->chooseleaf_descend_once)
+                                               recurse_tries = 1;
+                                       else
+                                               recurse_tries = choose_tries;
                                        osize += crush_choose_firstn(
                                                map,
                                                map->buckets[-1-w[i]],
@@ -734,9 +736,9 @@ int crush_do_rule(const struct crush_map *map,
                                                curstep->arg2,
                                                o+osize, j,
                                                choose_tries,
-                                               choose_leaf_tries ? choose_leaf_tries : choose_tries,
+                                               recurse_tries,
                                                recurse_to_leaf,
-                                               descend_once, c+osize);
+                                               c+osize);
                                } else {
                                        crush_choose_indep(
                                                map,
@@ -746,7 +748,8 @@ int crush_do_rule(const struct crush_map *map,
                                                curstep->arg2,
                                                o+osize, j,
                                                choose_tries,
-                                               choose_leaf_tries ? choose_leaf_tries : 1,
+                                               choose_leaf_tries ?
+                                                  choose_leaf_tries : 1,
                                                recurse_to_leaf,
                                                c+osize,
                                                0);