From 7654c96a7174950d2bf0ba6cf20ba8d0a20cf8f5 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 12 Sep 2014 14:05:33 -0700 Subject: [PATCH] Spare / replacement disk improvements for RAID, thanks to Caspar Smit --- raid/lang/en | 2 +- raid/log_parser.pl | 2 +- raid/raid-lib.pl | 6 +++--- raid/save_raid.cgi | 6 +++--- raid/view_raid.cgi | 6 +++++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/raid/lang/en b/raid/lang/en index 29f5b9424..400345b78 100644 --- a/raid/lang/en +++ b/raid/lang/en @@ -145,7 +145,7 @@ log_delete=Deleted RAID device $1 log_mkfs=Created $1 filesystem on $2 log_add=Added partition $2 to RAID device $1 log_remove=Removed partition $2 from RAID device $1 -log_replace=Hot replaced partition $2 in RAID device $1 with a spare partition +log_replace=Hot replaced partition $2 in RAID device $1 with spare partition $3 log_grow=Grown RAID device $1 to a total of $2 disks log_convert_to_raid6=Converted RAID5 device $1 to a RAID6 device log_convert_to_raid5=Converted RAID6 device $1 to a RAID5 device diff --git a/raid/log_parser.pl b/raid/log_parser.pl index d07897684..1cbf93b02 100755 --- a/raid/log_parser.pl +++ b/raid/log_parser.pl @@ -31,7 +31,7 @@ elsif ($action eq 'remove') { return &text('log_remove', "$object", "$p->{'disk'}"); } elsif ($action eq 'replace') { - return &text('log_replace', "$object", "$p->{'disk'}"); + return &text('log_replace', "$object", "$p->{'disk'}", "$p->{'disk2'}"); } elsif ($action eq 'grow') { return &text('log_grow', "$object", "$p->{'disk'}"); diff --git a/raid/raid-lib.pl b/raid/raid-lib.pl index cb708d230..24a34606c 100755 --- a/raid/raid-lib.pl +++ b/raid/raid-lib.pl @@ -562,14 +562,14 @@ if ($raid_mode eq "mdadm") { } } -# replace_partition(&raid, device) -# Hot replaces a partition with a spare +# replace_partition(&raid, device, spare) +# Hot replaces a data disk with a spare disk sub replace_partition { if ($raid_mode eq "mdadm") { # Call mdadm commands to replace local $out = &backquote_logged( - "mdadm --replace $_[0]->{'value'} $_[1] 2>&1"); + "mdadm --replace $_[0]->{'value'} $_[1] --with $_[2] 2>&1"); &error(&text('emdadmreplace', "$out")) if ($?); } } diff --git a/raid/save_raid.cgi b/raid/save_raid.cgi index d23309792..652fb639b 100755 --- a/raid/save_raid.cgi +++ b/raid/save_raid.cgi @@ -114,11 +114,11 @@ elsif ($in{'remove_det'}) { &redirect(""); } elsif ($in{'replace'}) { - # Hot replace a member disk with a spare + # Hot replace a data disk with a spare disk &lock_raid_files(); - &replace_partition($old, $in{'replacedisk'}); + &replace_partition($old, $in{'replacedisk'}, $in{'replacesparedisk'}); &unlock_raid_files(); - &webmin_log("replace", undef, $old->{'value'}, { 'disk' => $in{'replacedisk'} } ); + &webmin_log("replace", undef, $old->{'value'}, { 'disk' => $in{'replacedisk'} , 'disk2' => $in{'replacesparedisk'} } ); &redirect(""); } elsif ($in{'convert_to_raid6'}) { diff --git a/raid/view_raid.cgi b/raid/view_raid.cgi index 02e8d357c..469896c01 100755 --- a/raid/view_raid.cgi +++ b/raid/view_raid.cgi @@ -103,6 +103,7 @@ foreach $d (@devs) { } $rp .= "
\n"; push(@rdisks, [ $d->{'value'}, $name ]); + push(@datadisks, [ $d->{'value'}, $name ]); } } @@ -120,6 +121,7 @@ foreach $d (@devs) { local $name = &mount::device_name($d->{'value'}); $sp .= "$name
\n"; push(@rdisks, [ $d->{'value'}, $name ]); + push(@sparedisks, [ $d->{'value'}, $name ]); $sparescnt++; $newdisks++; push(@spares, [ "$newdisks", "+ $sparescnt" ]); @@ -165,8 +167,10 @@ if ($raid_mode eq "mdadm") { } if ($sparescnt > 0 && &get_mdadm_version() >= 3.3 && &supports_replace()) { @rdisks = sort { $a->[0] cmp $b->[0] } @rdisks; + @spares = sort { $a->[0] cmp $b->[0] } @spares; push(@grid, &ui_submit($text{'view_replace'}, "replace")." ". - &ui_select("replacedisk", undef, \@rdisks), + &ui_select("replacedisk", undef, \@datadisks)." with ". + &ui_select("replacesparedisk", undef, \@sparedisks), $text{'view_replacedesc'}); } if ($sparescnt > 0 && $lvl != 10) {