Changeset 767

Show
Ignore:
Timestamp:
03/09/07 21:31:15 (2 years ago)
Author:
hachi
Message:

iostat on linux doesn't show per-pertitions statistics, so when we map mogile devices to os devices, we need to upgrade the partitions to their parent devices.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/server/mogstored

    r725 r767  
    434434        $map->{$mogdevid} = $osdevid; 
    435435    } 
     436 
     437    if (lc($^O) eq 'linux') { 
     438        my %name_to_number; 
     439        my %number_to_name; 
     440 
     441        if (open my $partitions, '<', '/proc/partitions') { 
     442            <$partitions>; <$partitions>; # First two lines are for humans 
     443            while (my $line = <$partitions>) { 
     444                my ($major, $minor, $devname) = $line =~ 
     445                    m/^ \s* (\d+) \s+ (\d+) \s+ \d+ \s+ (\S+) \s* $/x; 
     446                my $devno = ($major << 8) + $minor; 
     447                $name_to_number{$devname} = $devno; 
     448                $number_to_name{$devno} = $devname; 
     449            } 
     450        } else { 
     451            warn "Unable to open /proc/partitions: $!"; 
     452        } 
     453 
     454        foreach my $mogdevid (keys %$map) { 
     455            my $original = $map->{$mogdevid}; 
     456            my $devname = $number_to_name{$original} or next; 
     457            if (my ($new) = $devname =~ m/^([hs]d\w)\d+$/) { 
     458                next unless $name_to_number{$new}; 
     459                $map->{$mogdevid} = $name_to_number{$new}; 
     460            } 
     461        } 
     462    } 
    436463    return $map; 
    437464}