summaryrefslogtreecommitdiffstats
path: root/perl-install/fs/dmraid.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/fs/dmraid.pm')
-rw-r--r--perl-install/fs/dmraid.pm75
1 files changed, 65 insertions, 10 deletions
diff --git a/perl-install/fs/dmraid.pm b/perl-install/fs/dmraid.pm
index eae1fdd86..7a279abc7 100644
--- a/perl-install/fs/dmraid.pm
+++ b/perl-install/fs/dmraid.pm
@@ -1,4 +1,4 @@
-package fs::dmraid; # $Id: dmraid.pm 265309 2010-01-27 00:28:23Z pterjan $
+package fs::dmraid;
use diagnostics;
use strict;
@@ -14,23 +14,54 @@ use fs::wild_device;
use run_program;
+=head1 SYNOPSYS
+
+Manage fake RAIDs using dmraid
+
+=head1 Functions
+
+=over
+
+=item init()
+
+Load kernel modules, init device mapper then scan for fake RAIDs.
+
+=cut
+
sub init() {
whereis_binary('dmraid') or die "dmraid not installed";
eval { modules::load('dm-mirror', 'dm-zero') };
devices::init_device_mapper();
if ($::isInstall) {
- call_dmraid('-ay');
+ foreach my $name (call_dmraid('-s', '-c', '-i')) {
+ chomp($name);
+ log::l("got: $name");
+ call_dmraid('-ay', '-i', '--rm_partitions', '-p', $name);
+ run_program::run('/sbin/kpartx', '-u', '-a', '/dev/mapper/' . $name);
+ }
}
1;
}
-#- call_dmraid is overloaded when debugging, see the end of this file
+=item call_dmraid($option, @args)
+
+Runs dmraid with $option & @args.
+It is overloaded when debugging, see the end of this file.
+
+=cut
+
sub call_dmraid {
my ($option, @args) = @_;
run_program::get_stdout('dmraid', $option, @args);
}
+=item check($in)
+
+Ensures dmraid is installed. If yes, calls init().
+
+=cut
+
sub check {
my ($in) = @_;
@@ -39,8 +70,13 @@ sub check {
1;
}
+=item _raid_devices_raw()
+
+Get the real VG names, needed for ddf1, and safer than begins_with for raid10
+
+=cut
+
sub _raid_devices_raw() {
- # get the real vg names, needed for ddf1, and safer than begins_with for raid10
log::l("_raid_devices_raw");
my %vgs;
my %pv2vg = map {
@@ -50,9 +86,10 @@ sub _raid_devices_raw() {
$vgs{$l{name}} = 1 if defined $l{spares};
if (/freeing device "(.*)", path "(.*)"/ && defined $vgs{$1}) {
log::l("$2 => $1");
- { $2 => $1 }
+ $2 => $1;
}
} call_dmraid(qw(-d -s -c -c));
+
map {
chomp;
log::l("got: $_");
@@ -109,6 +146,12 @@ sub _sets() {
@sets;
}
+=item vgs()
+
+Returns the list of VGs corresponding to dmraid
+
+=cut
+
sub vgs() {
map {
my $dev = "mapper/$_->{name}";
@@ -134,11 +177,15 @@ sub vgs() {
} _sets();
}
-# the goal is to handle migration from /dev/mapper/xxx1 to /dev/mapper/xxxp1,
-# as used by initrd/nash.
-# dmraid has been patched to follow xxxp1 device names.
-# so until the box has rebooted on new initrd/dmraid, we must cope with /dev/mapper/xxx1 device names
-# (cf #44182)
+=item migrate_device_names ($vg)
+
+Handles migration from /dev/mapper/xxx1 to /dev/mapper/xxxp1, as used by initrd/nash.
+dmraid has been patched to follow xxxp1 device names.
+So until the box has rebooted on new initrd/dmraid, we must cope with /dev/mapper/xxx1 device names
+(cf mdk#44182)
+
+=cut
+
sub migrate_device_names {
my ($vg) = @_;
@@ -154,6 +201,14 @@ sub migrate_device_names {
}
}
+=back
+
+=head1 Debugging
+
+If $ENV{DRAKX_DEBUG_DMRAID} is set, debugging dmraid is done.
+The C<call_dmraid()> function is overloaded and will spit out warnings.
+=cut
+
if ($ENV{DRAKX_DEBUG_DMRAID}) {
eval(<<'EOF');
my %debug_data = (