crush: generalize descend_once
[platform/adaptation/renesas_rcar/renesas_kernel.git] / net / ceph / crush / mapper.c
index e9256a3..0613dd2 100644 (file)
@@ -291,7 +291,6 @@ static int is_out(const struct crush_map *map,
  * @out: pointer to output vector
  * @outpos: our position in that vector
  * @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
  * @out2: second output vector for leaf items (if @recurse_to_leaf)
  */
 static int crush_choose_firstn(const struct crush_map *map,
@@ -302,7 +301,7 @@ static int crush_choose_firstn(const struct crush_map *map,
                               unsigned int attempts,
                               unsigned int recurse_attempts,
                               int recurse_to_leaf,
-                              int descend_once, int *out2)
+                              int *out2)
 {
        int rep;
        unsigned int ftotal, flocal;
@@ -389,7 +388,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;
@@ -414,10 +412,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 &&
@@ -639,7 +634,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);
@@ -703,6 +697,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]],
@@ -711,9 +713,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,
@@ -723,7 +725,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);