summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-06-11 22:17:14 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-06-11 22:17:14 +0000
commitb8d75ed5914466dfc5c07916ac167f8f4728888c (patch)
treeb1ae113abe5fcc13038f528a6bf0b9d5ed684da5
parentdf52dd03d51f1728f15db0d89df54532811c1870 (diff)
downloaddrakx-backup-do-not-use-b8d75ed5914466dfc5c07916ac167f8f4728888c.tar
drakx-backup-do-not-use-b8d75ed5914466dfc5c07916ac167f8f4728888c.tar.gz
drakx-backup-do-not-use-b8d75ed5914466dfc5c07916ac167f8f4728888c.tar.bz2
drakx-backup-do-not-use-b8d75ed5914466dfc5c07916ac167f8f4728888c.tar.xz
drakx-backup-do-not-use-b8d75ed5914466dfc5c07916ac167f8f4728888c.zip
include patch to autodetect raid arrays (still needs a kernel that implements the ioctl..)
-rw-r--r--perl-install/detect_devices.pm18
-rw-r--r--perl-install/fsedit.pm39
-rw-r--r--perl-install/install_any.pm3
-rw-r--r--perl-install/raid.pm2
4 files changed, 58 insertions, 4 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 03d90cda2..c12767aa7 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -355,6 +355,24 @@ sub hasMousePS2 {
my $t; sysread(tryOpen($_[0]) || return, $t, 256) != 1 || $t ne "\xFE";
}
+sub raidAutoStartIoctl {
+ eval { modules::load('md') };
+ my $md = devices::make("md0");
+ local *F;
+ sysopen F, $md, 2 or return;
+ ioctl F, 2324, 0;
+}
+
+sub raidAutoStart {
+ log::l("raidAutoStart");
+ my %personalities = ( '1' => 'linear', '2' => 'raid0', '3' => 'raid1', '4' => 'raid5' );
+ raidAutoStartIoctl() or log::l("warning, RAID_AUTORUN not supported by kernel"), return;
+ if (my @needed_perso = map { if_(/^kmod: failed.*md-personality-(.)/, $personalities{$1}) } syslog()) {
+ log::l("RAID: autostart needs personality from $_"), eval { modules::load($_) } foreach @needed_perso;
+ return raidAutoStartIoctl();
+ }
+}
+
#-######################################################################################
#- Wonderful perl :(
#-######################################################################################
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index bc2182255..5a25d55b3 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -60,7 +60,7 @@ sub typeOfPart { typeFromMagic(devices::make($_[0]), @partitions_signatures) }
#-######################################################################################
sub hds {
my ($drives, $flags) = @_;
- my (@hds, @lvms);
+ my (@hds, @lvms, @raid);
my $rc;
foreach (@$drives) {
@@ -104,7 +104,42 @@ sub hds {
push @{$lvm->{disks}}, $_;
}
}
- \@hds, \@lvms;
+ if ((my @parts = grep { isRAID($_) } map { partition_table::get_normal_parts($_) } @hds) && detect_devices::raidAutoStart()) {
+ my @mdstat = cat_("/proc/mdstat");
+ for (my $i=0 ; $i<@mdstat ; $i++) {
+ next if $mdstat[$i] !~ /^md(.).* ([^ \[\]]+) ([^ ]+\[[^ \]]+\])(.*)$/;
+ my ($nb, $level, $partcar, $partcdr) = ($1, $2, $3, $4);
+ $level =~ /raid(.)/ and $level = $1;
+ $partcar =~ /([^\[]+)/ or next;
+ my @thisparts = ( $1 );
+ while ($partcdr =~ /\s*([^\[]+)[^\]]+\](.*)/) {
+ push @thisparts, $1;
+ $partcdr = $2;
+ }
+ my $chunks = $mdstat[$i+1] =~ /([^ ]+) chunks/ ? $1 : "64k";
+ my @disks;
+ foreach my $part (@parts) {
+ if (grep /$part->{device}/, @thisparts) {
+ $part->{raid} = $nb;
+ delete $part->{mntpoint};
+ push @disks, $part;
+ }
+ }
+ my $type = typeOfPart("md$nb");
+ my $notformat = 0;
+ log::l("RAID: found md$nb (raid $level) chunks $chunks ", $type ? "type $type " : "", "with parts ", join(", ", @thisparts));
+ if (!$type) {
+ $type = 0x83;
+ $notformat = 1;
+ }
+ $raid[$nb] = { 'chunk-size' => $chunks, type => $type, disks => \@disks,
+ device => "md$nb", notFormatted => $notformat, level => $level };
+ }
+ require raid;
+ raid::update(@raid);
+ }
+
+ \@hds, \@lvms, \@raid;
}
sub readProcPartitions {
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 9bba376cb..077bc49f9 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -825,7 +825,7 @@ sub getHds {
# add2hash_($o->{partitioning}, { readonly => 1 }) if partition_table_raw::typeOfMBR($drives[0]{device}) eq 'system_commander';
getHds:
- my ($hds, $lvms) = catch_cdie { fsedit::hds(\@drives, $flags) }
+ my ($hds, $lvms, $raids) = catch_cdie { fsedit::hds(\@drives, $flags) }
sub {
$ok = 0;
my $err = $@; $err =~ s/ at (.*?)$//;
@@ -848,6 +848,7 @@ sub getHds {
$o->{hds} = $hds;
$o->{lvms} = $lvms;
+ $o->{raid}->{raid} = $raids;
$o->{fstab} = [ fsedit::get_fstab(@$hds, @$lvms) ];
fs::check_mounted($o->{fstab});
fs::merge_fstabs($o->{fstab}, $o->{manualFstab});
diff --git a/perl-install/raid.pm b/perl-install/raid.pm
index 1f2275706..b74c53e25 100644
--- a/perl-install/raid.pm
+++ b/perl-install/raid.pm
@@ -122,8 +122,8 @@ sub make {
isMDRAID($_) and make($raid, $_) foreach @{$part->{disks}};
my $dev = devices::make($part->{device});
eval { modules::load(module($part)) };
- run_program::run("raidstop", $dev);
&write($raid, "/etc/raidtab");
+ run_program::run("raidstop", $dev);
run_program::run("mkraid", "--really-force", $dev) or die
$::isStandalone ? _("mkraid failed (maybe raidtools are missing?)") : _("mkraid failed");
}