Skip to content

Commit

Permalink
Merge pull request ceph#3923 from ceph/wip-11079
Browse files Browse the repository at this point in the history
crush: fix get_weight and destroy for straw2 buckets

Reviewed-by: Loic Dachary <[email protected]>
  • Loading branch information
liewegas committed Mar 10, 2015
2 parents 9b4b350 + ac527a2 commit c35f422
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
13 changes: 13 additions & 0 deletions src/crush/crush.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ int crush_get_bucket_item_weight(const struct crush_bucket *b, int p)
return ((struct crush_bucket_tree *)b)->node_weights[crush_calc_tree_node(p)];
case CRUSH_BUCKET_STRAW:
return ((struct crush_bucket_straw *)b)->item_weights[p];
case CRUSH_BUCKET_STRAW2:
return ((struct crush_bucket_straw2 *)b)->item_weights[p];
}
return 0;
}
Expand Down Expand Up @@ -79,6 +81,14 @@ void crush_destroy_bucket_straw(struct crush_bucket_straw *b)
kfree(b);
}

void crush_destroy_bucket_straw2(struct crush_bucket_straw2 *b)
{
kfree(b->item_weights);
kfree(b->h.perm);
kfree(b->h.items);
kfree(b);
}

void crush_destroy_bucket(struct crush_bucket *b)
{
switch (b->alg) {
Expand All @@ -94,6 +104,9 @@ void crush_destroy_bucket(struct crush_bucket *b)
case CRUSH_BUCKET_STRAW:
crush_destroy_bucket_straw((struct crush_bucket_straw *)b);
break;
case CRUSH_BUCKET_STRAW2:
crush_destroy_bucket_straw2((struct crush_bucket_straw2 *)b);
break;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/test/cli/crushtool/straw2.t
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
$ crushtool -c "$TESTDIR/straw2.txt" -o straw2
$ rm straw2
$ crushtool -c $TESTDIR/straw2.txt -o straw2
$ crushtool -d straw2 -o straw2.txt.new
$ diff -b $TESTDIR/straw2.txt straw2.txt.new
$ rm straw2 straw2.txt.new
36 changes: 19 additions & 17 deletions src/test/cli/crushtool/straw2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,29 @@ type 2 default

# buckets
host host0 {
id -1 # do not change unnecessarily
# weight 1.000
alg foo
hash 0 # rjenkins1
item device0 weight 0.000
id -1 # do not change unnecessarily
# weight 1.000
alg straw2
hash 0 # rjenkins1
item device0 weight 1.000
}
default default {
id -2 # do not change unnecessarily
# weight 1.000
alg straw
hash 0 # rjenkins1
item host0 weight 0.000
id -2 # do not change unnecessarily
# weight 1.000
alg straw2
hash 0 # rjenkins1
item host0 weight 1.000
}

# rules
rule replicated_ruleset {
ruleset 0
type replicated
min_size 1
max_size 10
step take default
step chooseleaf firstn 0 type host
step emit
ruleset 0
type replicated
min_size 1
max_size 10
step take default
step chooseleaf firstn 0 type host
step emit
}

# end crush map

0 comments on commit c35f422

Please sign in to comment.