From 6b1f973b5d933656b4ad9a8bcfda63752e67d23b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 23 Mar 2008 14:15:17 -0700 Subject: [PATCH] crushtool: perl version hacks --- src/crush/old_sample.txt | 111 +++++++++++++++++++++++++++------------ src/crushtool.pl | 9 ++-- 2 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/crush/old_sample.txt b/src/crush/old_sample.txt index e138428982af4..54cf06a7bc4dd 100644 --- a/src/crush/old_sample.txt +++ b/src/crush/old_sample.txt @@ -1,37 +1,82 @@ -# types -type osd 0 -type cab 2 -type row 3 -type pool 10 - -# devices -device osd001 { - id 1; - weight 500; # optional -} -device cosd002 { id 2; weight 300; } -device cosd003 { id 3; } -device cosd004 { id 4; } -device cosd005 { id 5; } +# first define our types + + + type_id = 0 + + + type_id = 2 + + + type_id = 3 + + + type_id = 10 + + # hierarchy -bucket cab-d2 type cab { - id -1; # optional - alg straw; - item osd001; - item osd002 weight 600; - item osd003 weight 600; - item osd004 weight 600; - item osd005 weight 600; -} + + + id 1 + weight 500 + + + id 2 + weight 500 + + + id 3 + weight 500 + + + id 4 + weight 500 + + + id 5 + weight 500 + + + + + + alg straw + id -12 + + + + + weight 600 + + + +# +# +# weight 1.0 +# +# +# weight 3.0 +# +# + + + + + id 5 + weight 500 + + -rule normal { - pool 0; - type replicated; - min_size 1; - max_size 4; - step take(root); - step choose_indep(0, osd); - step emit; -} +# rules + + + pool 0 + type replicated + min_size 1 + mix_size 4 + step take root + step choose_indep 0 osd + step emit + + diff --git a/src/crushtool.pl b/src/crushtool.pl index 8e6f28b2aa7b6..01e1758694706 100755 --- a/src/crushtool.pl +++ b/src/crushtool.pl @@ -59,8 +59,9 @@ sub decompile_crush { $wrap->create(); - print "reading...\n"; + print "reading from $infn...\n"; my $r = $wrap->read_from_file($infn); + print "read, r = $r.\n"; die "can't read file $infn ($r)\n" if ($r != 0); @@ -80,11 +81,13 @@ sub decompile_crush { # devices my $max_devices = $wrap->get_max_devices(); + print "max $max_devices\n"; my %device_weight; my %name_map; for (my $id=0; $id < $max_devices; $id++) { my $name = $wrap->get_item_name($id); - next if $name eq ''; + $name ||= "device$id"; + #next if $name eq ''; $name_map{$id} = $name; print "device $id '$name'\n"; $arr->{'devices'}->{$type_map{0}}->{$name}->{'id'} = $id; @@ -144,7 +147,7 @@ sub compile_crush { print Dumper $arr; my $lowest = get_lowest($arr); - #print "lowest is $lowest\n"; + print "lowest is $lowest\n"; my %weights; # item id -> weight -- 2.39.5