From b686edae8c558917e7671d52be0ef13eb5d5b1fb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Mar 2015 06:32:51 -0700 Subject: [PATCH 1/3] crushtool: fix straw2 cli test Signed-off-by: Sage Weil --- src/test/cli/crushtool/straw2.t | 4 ++-- src/test/cli/crushtool/straw2.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/cli/crushtool/straw2.t b/src/test/cli/crushtool/straw2.t index fee1c67ae6286..8638dea5fb24c 100644 --- a/src/test/cli/crushtool/straw2.t +++ b/src/test/cli/crushtool/straw2.t @@ -1,2 +1,2 @@ - $ crushtool -c "$TESTDIR/straw2.txt" -o straw2 - $ rm straw2 + $ crushtool -c "$TESTDIR/straw2.txt" -o straw2 + $ rm straw2 diff --git a/src/test/cli/crushtool/straw2.txt b/src/test/cli/crushtool/straw2.txt index 9853f175e0d5a..6a4a7e59fa8a4 100644 --- a/src/test/cli/crushtool/straw2.txt +++ b/src/test/cli/crushtool/straw2.txt @@ -17,16 +17,16 @@ type 2 default host host0 { id -1 # do not change unnecessarily # weight 1.000 - alg foo + alg straw2 hash 0 # rjenkins1 - item device0 weight 0.000 + item device0 weight 1.000 } default default { id -2 # do not change unnecessarily # weight 1.000 - alg straw + alg straw2 hash 0 # rjenkins1 - item host0 weight 0.000 + item host0 weight 1.000 } # rules From 6445d9ee7290938de1e4ee9563912a6ab6d8ee5f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Mar 2015 06:38:06 -0700 Subject: [PATCH 2/3] crush: fix crush_get_bucket_item_weight and bucket destroy for straw2 Fixes: #11079 Signed-off-by: Sage Weil --- src/crush/crush.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/crush/crush.c b/src/crush/crush.c index c45b6f501b224..c0bcdb794355f 100644 --- a/src/crush/crush.c +++ b/src/crush/crush.c @@ -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; } @@ -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) { @@ -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; } } From ac527a2677802e4562a1806965990036b0967a92 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Mar 2015 06:45:01 -0700 Subject: [PATCH 3/3] crushtool: improve straw2 compile/decompile test This way it catches #11079. Signed-off-by: Sage Weil --- src/test/cli/crushtool/straw2.t | 6 ++++-- src/test/cli/crushtool/straw2.txt | 36 ++++++++++++++++--------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/test/cli/crushtool/straw2.t b/src/test/cli/crushtool/straw2.t index 8638dea5fb24c..86813384072b6 100644 --- a/src/test/cli/crushtool/straw2.t +++ b/src/test/cli/crushtool/straw2.t @@ -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 diff --git a/src/test/cli/crushtool/straw2.txt b/src/test/cli/crushtool/straw2.txt index 6a4a7e59fa8a4..0928aa5b92975 100644 --- a/src/test/cli/crushtool/straw2.txt +++ b/src/test/cli/crushtool/straw2.txt @@ -15,27 +15,29 @@ type 2 default # buckets host host0 { - id -1 # do not change unnecessarily - # weight 1.000 - alg straw2 - hash 0 # rjenkins1 - item device0 weight 1.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 straw2 - hash 0 # rjenkins1 - item host0 weight 1.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