Spare / replacement disk improvements for RAID, thanks to Caspar Smit

This commit is contained in:
Jamie Cameron
2014-09-12 14:05:33 -07:00
parent d245738402
commit 7654c96a71
5 changed files with 13 additions and 9 deletions

View File

@@ -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

View File

@@ -31,7 +31,7 @@ elsif ($action eq 'remove') {
return &text('log_remove', "<tt>$object</tt>", "<tt>$p->{'disk'}</tt>");
}
elsif ($action eq 'replace') {
return &text('log_replace', "<tt>$object</tt>", "<tt>$p->{'disk'}</tt>");
return &text('log_replace', "<tt>$object</tt>", "<tt>$p->{'disk'}</tt>", "<tt>$p->{'disk2'}</tt>");
}
elsif ($action eq 'grow') {
return &text('log_grow', "<tt>$object</tt>", "<tt>$p->{'disk'}</tt>");

View File

@@ -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', "<tt>$out</tt>")) if ($?);
}
}

View File

@@ -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'}) {

View File

@@ -103,6 +103,7 @@ foreach $d (@devs) {
}
$rp .= "<br>\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<br>\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) {