summary refs log tree commit diff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/ceph/crush/mapper.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index a71f8c4c78ec..125dbd04f2b6 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -457,13 +457,13 @@ reject:
 static void crush_choose_indep(const struct crush_map *map,
 			      struct crush_bucket *bucket,
 			      const __u32 *weight, int weight_max,
-			      int x, int numrep, int type,
+			       int x, int left, int numrep, int type,
 			      int *out, int outpos,
 			      int recurse_to_leaf,
 			      int *out2)
 {
 	struct crush_bucket *in = bucket;
-	int left = numrep - outpos;
+	int endpos = outpos + left;
 	int rep;
 	unsigned int ftotal;
 	int r;
@@ -476,14 +476,14 @@ static void crush_choose_indep(const struct crush_map *map,
 		bucket->id, x, outpos, numrep);
 
 	/* initially my result is undefined */
-	for (rep = outpos; rep < numrep; rep++) {
+	for (rep = outpos; rep < endpos; rep++) {
 		out[rep] = CRUSH_ITEM_UNDEF;
 		if (out2)
 			out2[rep] = CRUSH_ITEM_UNDEF;
 	}
 
 	for (ftotal = 0; left > 0 && ftotal < map->choose_total_tries; ftotal++) {
-		for (rep = outpos; rep < numrep; rep++) {
+		for (rep = outpos; rep < endpos; rep++) {
 			if (out[rep] != CRUSH_ITEM_UNDEF)
 				continue;
 
@@ -551,7 +551,7 @@ static void crush_choose_indep(const struct crush_map *map,
 
 				/* collision? */
 				collide = 0;
-				for (i = outpos; i < numrep; i++) {
+				for (i = outpos; i < endpos; i++) {
 					if (out[i] == item) {
 						collide = 1;
 						break;
@@ -565,7 +565,7 @@ static void crush_choose_indep(const struct crush_map *map,
 						crush_choose_indep(map,
 								   map->buckets[-1-item],
 								   weight, weight_max,
-								   x, rep+1, 0,
+								   x, 1, numrep, 0,
 								   out2, rep,
 								   0, NULL);
 						if (out2[rep] == CRUSH_ITEM_NONE) {
@@ -590,7 +590,7 @@ static void crush_choose_indep(const struct crush_map *map,
 			}
 		}
 	}
-	for (rep = outpos; rep < numrep; rep++) {
+	for (rep = outpos; rep < endpos; rep++) {
 		if (out[rep] == CRUSH_ITEM_UNDEF) {
 			out[rep] = CRUSH_ITEM_NONE;
 		}
@@ -698,7 +698,7 @@ int crush_do_rule(const struct crush_map *map,
 						map,
 						map->buckets[-1-w[i]],
 						weight, weight_max,
-						x, numrep,
+						x, numrep, numrep,
 						curstep->arg2,
 						o+osize, j,
 						recurse_to_leaf,