Skip to content

Commit

Permalink
Crush: Ensuring at most num-rep osds are selected
Browse files Browse the repository at this point in the history
Crush temporary buffers are allocated as per replica size configured
by the user.When there are more final osds (to be selected as per
rule) than the replicas, buffer overlaps and it causes crash.Now, it
ensures that at most num-rep osds are selected even if more number of
osds are allowed by indep rule. The fix for firstn rules is already
merged as part of bug #9492. Required test files are added.

Fixes: #9492

Signed-off-by: Johnu George johnugeo@cisco.com
  • Loading branch information
Johnu George committed Oct 4, 2014
1 parent 38dde3d commit 234b066
Show file tree
Hide file tree
Showing 3 changed files with 462 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/crush/mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ int crush_do_rule(const struct crush_map *map,
__u32 step;
int i, j;
int numrep;
int out_size;
/*
* the original choose_total_tries value was off by one (it
* counted "retries" and not "tries"). add one.
Expand Down Expand Up @@ -807,11 +808,13 @@ int crush_do_rule(const struct crush_map *map,
c+osize,
0);
} else {
out_size = ((numrep < (result_max-osize)) ?
numrep : (result_max-osize));
crush_choose_indep(
map,
map->buckets[-1-w[i]],
weight, weight_max,
x, numrep, numrep,
x, out_size, numrep,
curstep->arg2,
o+osize, j,
choose_tries,
Expand All @@ -820,7 +823,7 @@ int crush_do_rule(const struct crush_map *map,
recurse_to_leaf,
c+osize,
0);
osize += numrep;
osize += out_size;
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/test/cli/crushtool/test-map-firstn-indep.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$ crushtool -c "$TESTDIR/test-map-firstn-indep.txt" -o "$TESTDIR/test-map-firstn-indep.crushmap"
$ crushtool -i "$TESTDIR/test-map-firstn-indep.crushmap" --test --rule 0 --x 1 --show-bad-mappings
bad mapping rule 0 x 1 num_rep 9 result [93,80,88,87,56,50,53,72]
bad mapping rule 0 x 1 num_rep 10 result [93,80,88,87,56,50,53,72]
$ crushtool -i "$TESTDIR/test-map-firstn-indep.crushmap" --test --rule 1 --x 1 --show-bad-mappings
bad mapping rule 1 x 1 num_rep 3 result [93,56]
bad mapping rule 1 x 1 num_rep 4 result [93,56]
bad mapping rule 1 x 1 num_rep 5 result [93,56]
bad mapping rule 1 x 1 num_rep 6 result [93,56]
bad mapping rule 1 x 1 num_rep 7 result [93,56]
bad mapping rule 1 x 1 num_rep 8 result [93,56]
bad mapping rule 1 x 1 num_rep 9 result [93,56]
bad mapping rule 1 x 1 num_rep 10 result [93,56]
$ rm -f "$TESTDIR/test-map-firstn-indep.crushmap"
Loading

0 comments on commit 234b066

Please sign in to comment.