diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-06-20 06:38:06 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-06-20 06:38:06 +0000 |
commit | 5c8010ccef4dcc91d572ee09e5ce1c7cbf575581 (patch) | |
tree | 79155bc13a056fee32077819a34692198b6b4984 /perl-install | |
parent | a00c3995a27103b97534c3957dff9441874fd9ce (diff) | |
download | drakx-5c8010ccef4dcc91d572ee09e5ce1c7cbf575581.tar drakx-5c8010ccef4dcc91d572ee09e5ce1c7cbf575581.tar.gz drakx-5c8010ccef4dcc91d572ee09e5ce1c7cbf575581.tar.bz2 drakx-5c8010ccef4dcc91d572ee09e5ce1c7cbf575581.tar.xz drakx-5c8010ccef4dcc91d572ee09e5ce1c7cbf575581.zip |
initial dmraid support
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/fs/dmraid.pm | 55 | ||||
-rw-r--r-- | perl-install/fs/proc_partitions.pm | 2 | ||||
-rw-r--r-- | perl-install/fsedit.pm | 28 | ||||
-rw-r--r-- | perl-install/install2.pm | 3 |
4 files changed, 87 insertions, 1 deletions
diff --git a/perl-install/fs/dmraid.pm b/perl-install/fs/dmraid.pm new file mode 100644 index 000000000..1a0268014 --- /dev/null +++ b/perl-install/fs/dmraid.pm @@ -0,0 +1,55 @@ +package fs::dmraid; # $Id$ + +use diagnostics; +use strict; + +#-###################################################################################### +#- misc imports +#-###################################################################################### +use common; +use modules; +use devices; +use fs::type; +use run_program; + + +init() or log::l("dmraid::init failed"); + +sub init() { + eval { modules::load('dm-mirror') }; + devices::init_device_mapper(); + if ($::isInstall) { + run_program::run('dmraid', '-ay'); + } + 1; +} + +sub check { + my ($in) = @_; + + $in->do_pkgs->ensure_binary_is_installed('dmraid', 'dmraid') or return; + init(); + 1; +} + +sub pvs_and_vgs() { + map { + my @l = split(':'); + { pv => $l[0], format => $l[1], vg => $l[2], level => $l[3], status => $l[4] }; + } run_program::get_stdout('dmraid', '-rcc'); +} + +sub vgs() { + map { + my $dev = "mapper/$_->{vg}"; + my $vg = fs::subpart_from_wild_device_name("/dev/$dev"); + add2hash($vg, { media_type => 'hd', prefix => $dev, bus => "dm_$_->{format}" }); + $vg; + } grep { $_->{status} eq 'ok' } uniq_ { $_->{vg} } pvs_and_vgs(); +} + +sub pvs() { + map { $_->{pv} } grep { $_->{status} eq 'ok' } pvs_and_vgs(); +} + +1; diff --git a/perl-install/fs/proc_partitions.pm b/perl-install/fs/proc_partitions.pm index 1cb3acfd1..1d40840f5 100644 --- a/perl-install/fs/proc_partitions.pm +++ b/perl-install/fs/proc_partitions.pm @@ -59,6 +59,8 @@ sub read { sub compare { my ($hd) = @_; + $hd->{bus} =~ /^dm_/ and log::l("skipping /proc/partititions check for dmraid $hd->{device}"), return; + my @l1 = partition_table::get_normal_parts($hd); my @l2 = grep { $_->{rootDevice} eq $hd->{device} } &read([$hd]); diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 1ca3e1f3d..e2000b2b1 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -98,6 +98,31 @@ sub lvms { @lvms; } +sub handle_dmraid { + my ($drives) = @_; + + @$drives > 1 or return; + + devices::make($_->{device}) foreach @$drives; + + require fs::dmraid; + + my @pvs = fs::dmraid::pvs(); + my @vgs = fs::dmraid::vgs(); + log::l(sprintf('dmraid: pvs = [%s], vgs = [%s]', + join(' ', @pvs), + join(' ', map { $_->{device} } @vgs))); + + my @used_hds = map { + my $part = fs::get::device2part($_, $drives) or log::l("handle_dmraid: can't find $_ in known drives"); + if_($part, $part); + } @pvs; + + @$drives = difference2($drives, \@used_hds); + + push @$drives, @vgs; +} + sub get_hds { my ($o_flags, $o_in) = @_; my $flags = $o_flags || {}; @@ -105,6 +130,9 @@ sub get_hds { my @drives = detect_devices::hds(); + #- replace drives used in dmraid by the merged name + handle_dmraid(\@drives); + foreach my $hd (@drives) { $hd->{file} = devices::make($hd->{device}); $hd->{prefix} ||= $hd->{device}; diff --git a/perl-install/install2.pm b/perl-install/install2.pm index aaca3a6dd..3b9d1ef5f 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -210,7 +210,8 @@ sub formatPartitions { raid::prepare_prefixed($o->{all_hds}{raids}); #- needed by lilo - if (my @vgs = map { $_->{VG_name} } @{$o->{all_hds}{lvms}}) { + if (-d '/dev/mapper') { + my @vgs = map { $_->{VG_name} } @{$o->{all_hds}{lvms}}; cp_af("/dev/$_", "$::prefix/dev") foreach 'mapper', @vgs; } } |