From 5b79623823350d79e58b0375ccdef294e24d4848 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 20 May 2014 19:47:18 +0200 Subject: partially podify some modules --- perl-install/raid.pm | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'perl-install/raid.pm') diff --git a/perl-install/raid.pm b/perl-install/raid.pm index e65ee0676..6ae99a8d8 100644 --- a/perl-install/raid.pm +++ b/perl-install/raid.pm @@ -13,6 +13,14 @@ use run_program; use devices; use modules; +=head1 SYNOPSYS + +Manage regular soft RAID (MD=Multiple Drive). + +=over + +=cut + sub max_nb() { 31 } sub check_prog { @@ -38,6 +46,12 @@ sub new { $md_part; } +=item add() + +Add a partition to a RAID array + +=cut + sub add { my ($md_part, $part) = @_; $md_part->{isMounted} and die N("Cannot add a partition to _formatted_ RAID %s", $md_part->{device}); @@ -49,6 +63,12 @@ sub add { update($md_part); } +=item delete() + +Remove a partition from a RAID array + +=cut + sub delete { my ($raids, $md_part) = @_; inactivate_and_dirty($md_part); @@ -96,10 +116,22 @@ sub updateSize { }; } +=item allmodules() + +Return list of the RAID modules we support + +=cut + sub allmodules { ('raid0', 'raid1', 'raid10', 'raid456'); } +=item module($part) + +Return list of modules need by a md device (according to its RAID level) + +=cut + sub module { my ($part) = @_; my $level = $part->{level}; @@ -173,18 +205,45 @@ sub inactivate_and_dirty { set_isFormatted($part, 0); } +=item active_mds() + +Return list of active MDs + +=cut + sub active_mds() { map { if_(/^(md\S+)\s*:\s*active/, $1) } cat_("/proc/mdstat"); } + +=item inactive_mds() + +Return list of inactive MDs + +=cut + sub inactive_mds() { map { if_(/^(md\S+)\s*:\s*inactive/, $1) } cat_("/proc/mdstat"); } +=item free_mds() + +Return list of unused MD device nodes + +=cut + sub free_mds { my ($raids) = @_; difference2([ map { "md$_" } 0 .. max_nb() ], [ map { $_->{device} } @$raids ]); } +=item detect_durting_install() + +Load RAID modules. +Stop RAIDS that might have been started too early by udev. +Scan & starts RAID arrays, then stop any inactive md. + +=cut + sub detect_during_install { my (@parts) = @_; eval { modules::load($_) } foreach allmodules(); @@ -198,6 +257,12 @@ sub detect_during_install { stop_inactive_mds(); } +=item stop_inactive_mds() + +Stop any inactive md. + +=cut + sub stop_inactive_mds() { foreach (inactive_mds()) { log::l("$_ is an inactive md, we stop it to ensure it doesn't busy devices"); @@ -205,6 +270,12 @@ sub stop_inactive_mds() { } } +=item detect_during_install_once(@parts) + +Scan & starts RAID arrays, then stop any inactive md. + +=cut + sub detect_during_install_once { my (@parts) = @_; devices::make("md$_") foreach 0 .. max_nb(); @@ -256,11 +327,23 @@ sub get_existing { $raids; } +=item is_active($dev) + +Is it an?active md + +=cut + sub is_active { my ($dev) = @_; member($dev, active_mds()); } +=item write_conf() + +Write /etc/mdadm.conf + +=cut + sub write_conf { my ($raids) = @_; @@ -301,4 +384,8 @@ sub parse_mdadm_conf { \%conf; } +=back + +=cut + 1; -- cgit v1.2.1