From: Sage Weil Date: Fri, 31 Oct 2008 18:52:25 +0000 (-0700) Subject: makefile: make --with-debug work, fix build errors X-Git-Tag: v0.5~135 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f1eeff5b871b80e6ad3519ef13369d5ae996cda;p=ceph.git makefile: make --with-debug work, fix build errors --- diff --git a/configure.ac b/configure.ac index dfb322213a2b..6ed01f6750ba 100644 --- a/configure.ac +++ b/configure.ac @@ -34,9 +34,9 @@ AC_CHECK_LIB([pthread], [pthread_create]) # debug crap? AC_ARG_WITH([debug], [AS_HELP_STRING([--with-debug], [build extra debug binaries])], - [], + [with_debug=yes], [with_debug=no]) -AM_CONDITIONAL(WITH_DEBUG, [test "WITH_DEBUG" = "1"]) +AM_CONDITIONAL(WITH_DEBUG, test "$with_debug" = "yes") # fuse? AC_ARG_WITH([fuse], diff --git a/src/Makefile.am b/src/Makefile.am index c704285dd512..d14dc2d9cd83 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ monmaptool_LDADD = libcommon.a crushtool_SOURCES = crushtool.cc crushtool_LDADD = libcommon.a libcrush.a osdmaptool_SOURCES = osdmaptool.cc -osdmaptool_LDADD = libmon.a libcommon.a libcrush.a +osdmaptool_LDADD = libcommon.a libcrush.a # mds cmds_SOURCES = cmds.cc msg/SimpleMessenger.cc diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 3cbee456ce59..d2f81a745786 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -5,7 +5,7 @@ #define __CRUSH_WRAPPER_H #define BUG_ON(x) assert(!(x)) -#include "include/inttypes.h" /* just for int types */ +#include "include/types.h" extern "C" { #include "crush.h" diff --git a/src/crushtool.pl b/src/crushtool.pl deleted file mode 100755 index 01e175869470..000000000000 --- a/src/crushtool.pl +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/perl - -use Config::General; -use Tie::IxHash; -use Data::Dumper; - -use strict; - -use CrushWrapper; - -my $usage = "crushtool infile\n"; -my $fn = shift @ARGV || die $usage; - -my $alg_types = { - uniform => 1, - list => 2, - tree => 3, - straw => 4 -}; -my $alg_names = { - 1 => 'uniform', - 2 => 'list', - 3 => 'tree', - 4 => 'straw' }; - -my $wrap = new CrushWrapper::CrushWrapper; - -&compile_crush($fn, "$fn.out"); -&decompile_crush("$fn.out", "$fn.out.out"); - -# find lowest id number used -sub get_lowest { - my $item = shift; - return unless ref $item; - - my $lowest = 0; - - if (ref $item eq 'HASH') { - $lowest = $item->{'id'} if $lowest > $item->{'id'}; - foreach my $key (keys %{$item}) { - #next if grep { $key eq $_ } qw(type rule); - my $sublowest = get_lowest($item->{$key}); - $lowest = $sublowest if $lowest > $sublowest; - } - } elsif (ref $item eq 'ARRAY') { - foreach my $element (@{$item}) { - my $sublowest = get_lowest($element); - $lowest = $sublowest if $lowest > $sublowest; - } - } - - return $lowest; -} - - -sub decompile_crush { - my $infn = shift @_; - my $outfn = shift @_; - - $wrap->create(); - - 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); - - my $arr; - - # types - my $types = $wrap->get_num_type_names(); - my %type_map; - for (my $id=0; $types > 0; $id++) { - my $name = $wrap->get_type_name($id); - next if $name eq ''; - $types--; - $type_map{$id} = $name; - print "type $id is '$name'\n"; - $arr->{'types'}->{'type'}->{$name}->{'type_id'} = $id; - } - - # 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); - $name ||= "device$id"; - #next if $name eq ''; - $name_map{$id} = $name; - print "device $id '$name'\n"; - $arr->{'devices'}->{$type_map{0}}->{$name}->{'id'} = $id; - my $off = $wrap->get_device_offload($id); - if ($off) { - my $off = (0x10000 - $off) / 0x10000; - $arr->{'devices'}->{$type_map{0}}->{$name}->{'offload'} = $off; - } - } - - # get bucket names - my $max_buckets = $wrap->get_max_buckets(); - for (my $id=-1; $id > -1-$max_buckets; $id--) { - my $name = $wrap->get_item_name($id); - next if $name eq ''; - $name_map{$id} = $name; - } - - # do buckets - my $max_buckets = $wrap->get_max_buckets(); - for (my $id=-1; $id > -1-$max_buckets; $id--) { - my $name = $wrap->get_item_name($id); - next if $name eq ''; - print "bucket $id '$name'\n"; - my $alg = $wrap->get_bucket_alg($id); - my $type = $wrap->get_bucket_type($id); - $arr->{'buckets'}->{$type_map{$type}}->{$name}->{'id'} = $id; - $arr->{'buckets'}->{$type_map{$type}}->{$name}->{'alg'} = $alg_names->{$alg}; - my $n = $wrap->get_bucket_size($id); - for (my $i=0; $i<$n; $i++) { - my $item = $wrap->get_bucket_item($id, $i); - my $weight = $wrap->get_bucket_item_weight($id, $i); - next unless $weight; - $weight /= 0x10000; - $arr->{'buckets'}->{$type_map{$type}}->{$name}->{'item'}->{$name_map{$item}}->{'weight'} = $weight; - } - } - - - - print Dumper $arr; - -} - -sub compile_crush { - my $infn = shift @_; - my $outfn = shift @_; - - $wrap->create(); - - tie my %conf, "Tie::IxHash"; - %conf = Config::General::ParseConfig( -ConfigFile => $fn, - -Tie => "Tie::IxHash", - -MergeDuplicateBlocks => 1 ); - - my $arr = \%conf; - print Dumper $arr; - - my $lowest = get_lowest($arr); - print "lowest is $lowest\n"; - - my %weights; # item id -> weight - - # types - my %type_ids; - foreach my $item_type (keys %{$arr->{'types'}->{'type'}}) { - my $type_id = $arr->{'types'}->{'type'}->{$item_type}->{'type_id'}; - print "type $type_id '$item_type'\n"; - $type_ids{$item_type} = $type_id; - $wrap->set_type_name($type_id, $item_type); - } - - # build device table - my %device_ids; # name -> id - foreach my $item_type (keys %{$arr->{'devices'}}) { - foreach my $name (keys %{$arr->{'devices'}->{$item_type}}) { - my $id = $arr->{'devices'}->{$item_type}->{$name}->{'id'}; - if (!defined $id || $id < 0) { - die "invalid device id for $item_type $name: id is required and must be non-negative"; - } - $wrap->set_item_name($id, $name); - - my $w = $arr->{'devices'}->{$item_type}->{$name}->{'weight'}; - $weights{$id} = $w; - $device_ids{$name} = $id; - print "device $id '$name' weight $w\n"; - } - } - - # build bucket table - my %bucket_ids; - foreach my $bucket_type (keys %{$arr->{'buckets'}}) { - foreach my $name (keys %{$arr->{'buckets'}->{$bucket_type}}) { - # verify type - unless (defined $type_ids{$bucket_type}) { - die "invalid bucket type $bucket_type\n"; - } - - # id - my $id = $arr->{'buckets'}->{$bucket_type}->{$name}->{'id'}; - if (defined $id && $id > -1) { - die "invalid bucket id for $bucket_type $name: id must be negative"; - } elsif (!defined $id) { - # get the next lower ID number and inject it into the config hash - $id = --$lowest; - $arr->{'buckets'}->{$bucket_type}->{$name}->{'id'} = $id; - } - - $wrap->set_item_name($id, $name); - $bucket_ids{$name} = $id; - - my @item_ids; - my @weights; - my $myweight; - foreach my $item_name (keys %{$arr->{'buckets'}->{$bucket_type}->{$name}->{'item'}}) { - my $id = $wrap->get_item_id($item_name); - push @item_ids, $id; - my $weight = $arr->{'buckets'}->{$bucket_type}->{$name}->{'item'}->{$item_name}->{'weight'}; - $weight ||= $weights{$id}; - push(@weights, $weight * 65536); # 16.16 fixed point - $myweight += $weight; - } - - my $alg = $arr->{'buckets'}->{$bucket_type}->{$name}->{'alg'}; - $alg = 'straw' if !$alg; - die "invalid bucket alg $alg\n" - unless $alg_types->{$alg}; - - my $typeid = $type_ids{$bucket_type}; - my $algid = $alg_types->{$alg}; - print "\tid $id\n"; - print "\talg $alg ($algid)\n"; - print "\ttype $bucket_type ($typeid)\n"; - print "\titems @item_ids\n"; - print "\tweights @weights\n"; - - # id, alg, type, size, items, weights - #TODO: pass the correct value for type to add_bucket - my $result = $wrap->add_bucket($id, $algid, $typeid, - scalar(@item_ids), \@item_ids, \@weights); - #print "\t.. $result\n\n"; - print "\tweight $myweight\n"; - $weights{$id} = $myweight; - } - } - - # rules - for my $rule_name (keys %{$arr->{'rules'}->{'rule'}}) { - my $r = $arr->{'rules'}->{'rule'}->{$rule_name}; - my $pool = $r->{'pool'}; - #my $typeid = $rule_types{$r->{'type'}}; - my $min_size = $r->{'min_size'}; - my $max_size = $r->{'max_size'}; - - } - - $wrap->finalize; - $wrap->write_to_file($outfn); - 1; -} - - - -print "Line: " . __LINE__ ."\n"; - - -=item - -/*** BUCKETS ***/ -enum { - CRUSH_BUCKET_UNIFORM = 1, - CRUSH_BUCKET_LIST = 2, - CRUSH_BUCKET_TREE = 3, - CRUSH_BUCKET_STRAW = 4 -}; - -/*** RULES ***/ -enum { - CRUSH_RULE_NOOP = 0, - CRUSH_RULE_TAKE = 1, /* arg1 = value to start with */ - CRUSH_RULE_CHOOSE_FIRSTN = 2, /* arg1 = num items to pick */ - /* arg2 = type */ - CRUSH_RULE_CHOOSE_INDEP = 3, /* same */ - CRUSH_RULE_EMIT = 4 /* no args */ -}; - -=cut diff --git a/src/fakefuse.cc b/src/fakefuse.cc index 9dce514d2857..db4356e7aa53 100644 --- a/src/fakefuse.cc +++ b/src/fakefuse.cc @@ -123,7 +123,7 @@ int main(int argc, const char **argv) { // build initial osd map { OSDMap map; - map.build_simple(0, monmap->fsid, g_conf.num_osd, g_conf.osd_pg_bits, 0); + map.build_simple(0, monmap->fsid, g_conf.num_osd, 0, g_conf.osd_pg_bits, g_conf.osd_lpg_bits, 0); bufferlist bl; map.encode(bl); Messenger *messenger = new FakeMessenger(entity_name_t::ADMIN(-1)); diff --git a/src/fakesyn.cc b/src/fakesyn.cc index 213d4285cd3f..804826bdb640 100644 --- a/src/fakesyn.cc +++ b/src/fakesyn.cc @@ -122,7 +122,8 @@ int main(int argc, const char **argv) // build initial osd map { OSDMap map; - map.build_simple(0, monmap->fsid, g_conf.num_osd, g_conf.osd_pg_bits, 0); + map.build_simple(0, monmap->fsid, g_conf.num_osd, 0, + g_conf.osd_pg_bits, g_conf.osd_lpg_bits, 0); bufferlist bl; map.encode(bl); Messenger *messenger = new FakeMessenger(entity_name_t::ADMIN(-1)); diff --git a/src/msg/FakeMessenger.cc b/src/msg/FakeMessenger.cc index c56b980e8e60..71b99cff2068 100644 --- a/src/msg/FakeMessenger.cc +++ b/src/msg/FakeMessenger.cc @@ -214,7 +214,8 @@ int fakemessenger_do_loop_2() // encode if (m->empty_payload()) m->encode_payload(); - ceph_msg_header env = m->get_env(); + ceph_msg_header head = m->get_header(); + ceph_msg_footer foot = m->get_footer(); bufferlist front; front.claim( m->get_payload() ); bufferlist data; @@ -224,7 +225,7 @@ int fakemessenger_do_loop_2() delete m; // decode - m = decode_message(env, front, data); + m = decode_message(head, foot, front, data); assert(m); } diff --git a/src/psim.cc b/src/psim.cc index 46d40f581f2d..de71dbf1fdb7 100644 --- a/src/psim.cc +++ b/src/psim.cc @@ -26,7 +26,7 @@ int main(int argc, char **argv) } ceph_file_layout layout = g_default_file_layout; - layout.fl_pg_preferred = 2; + //layout.fl_pg_preferred = 2; for (int f = 1; f < 10000; f++) { // files for (int b = 0; b < 4; b++) { // blocks object_t oid(f, b);