Raid expansion support
authorJamie Cameron <jcameron@webmin.com>
Wed, 18 Feb 2009 06:13:20 +0000 (06:13 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 18 Feb 2009 06:13:20 +0000 (06:13 +0000)
raid/CHANGELOG
raid/lang/en
raid/raid-lib.pl
raid/save_raid.cgi
raid/view_raid.cgi

index f938ee9..06b860a 100644 (file)
@@ -15,3 +15,5 @@ Added a section for configuring RAID problem notification when using MDADM.
 Converted all pages to use the new Webmin UI library, for a more consistent look.
 Added a confirmation page before deleting a RAID array.
 Create /dev/md* device file if missing when creating a RAID set.
+---- Changes since 1.450 ----
+Added a button for changing the number of active devices in a RAID 5 or 6 set, thanks to Diego Zuccato.
index 039febc..d4eb957 100644 (file)
@@ -84,6 +84,8 @@ view_delete=Delete RAID array
 view_deletedesc=Click this button to totally remove this RAID device. Any data that it contains will almost certainly be lost!
 view_remove=Remove partition:
 view_removedesc=Select a partition that is part of the RAID device and click this button to remove it. This may cause data to be lost!
+view_grow=Grow RAID:
+view_growdesc=Grow array (convert hot spares to active members)
 view_state=RAID status
 view_rebuild=Rebuilding progress
 view_newmount=Mount RAID on:
@@ -107,6 +109,7 @@ eforce=You must force the initialisation of this RAID : $1
 emdadmstop=<tt>mdadm</tt> in <tt>--stop</tt> mode failed : $1
 emdadmcreate=<tt>mdadm</tt> in <tt>--create</tt> mode failed : $1
 emdadmadd=<tt>mdadm</tt> in <tt>--manage --add</tt> mode failed : $1
+emdadmgrow=<tt>mdadm</tt> in <tt>--grow</tt> mode failed : $1
 emdadmremove=<tt>mdadm</tt> in <tt>--manage --remove</tt> mode failed : $1
 emdadmfail=<tt>mdadm</tt> in <tt>--manage --fail</tt> mode failed : $1
 
index 46f635e..75071a5 100644 (file)
@@ -382,6 +382,19 @@ if ($raid_mode eq "mdadm") {
        }
 }
 
+# grow(&raid, totaldisks)
+# Grows a RAID set to contain totaldisks active partitions
+sub grow
+{
+if ($raid_mode eq "mdadm") {
+       # Call mdadm command to add
+       $cmd="mdadm --grow $_[0]->{'value'} -n $_[1] 2>&1";
+       local $out = &backquote_logged(
+               $cmd);
+       &error(&text('emdadmgrow', "<tt>'$cmd' -> $out</tt>")) if ($?);
+       }
+}
+
 # remove_partition(&raid, device)
 # Removes a device from some RAID set, both in the config file and for real
 sub remove_partition
index ead0b78..11474f4 100755 (executable)
@@ -71,6 +71,14 @@ elsif ($in{'add'}) {
        &webmin_log("add", undef, $old->{'value'}, { 'disk' => $in{'disk'} } );
        &redirect("");
        }
+elsif ($in{'grow'}) {
+       # Grow the array
+       &lock_raid_files();
+       &grow($old, $in{'ndisk'});
+       &unlock_raid_files();
+       &webmin_log("grow", undef, $old->{'value'}, { 'disk' => $in{'ndisk'} } );
+       &redirect("");
+       }
 elsif ($in{'remove'}) {
        # Remove a disk from a RAID set
        &lock_raid_files();
index 9221753..389c2b4 100755 (executable)
@@ -87,7 +87,8 @@ if ($raid->{'rebuild'}) {
 
 # Display partitions in RAID
 $rp = undef;
-foreach $d (&find('device', $raid->{'members'})) {
+@devs = &find('device', $raid->{'members'});
+foreach $d (@devs) {
        if (&find('raid-disk', $d->{'members'}) ||
             &find('parity-disk', $d->{'members'})) {
                local $name = &mount::device_name($d->{'value'});
@@ -104,11 +105,17 @@ print &ui_table_row($text{'view_disks'}, $rp);
 
 # Display spare partitions
 $sp = undef;
-foreach $d (&find('device', $raid->{'members'})) {
+$sparescnt = 0;
+$newdisks = @rdisks;
+@spares = ( );
+foreach $d (@devs) {
        if (&find('spare-disk', $d->{'members'})) {
                local $name = &mount::device_name($d->{'value'});
                $sp .= "$name<br>\n";
                push(@rdisks, [ $d->{'value'}, $name ]);
+               $sparescnt++;
+               $newdisks++;
+               push(@spares, [ "$newdisks", "+ $sparescnt" ]);
                }
        }
 if ($sp) {
@@ -139,6 +146,11 @@ if ($raid_mode eq "mdadm") {
                            &ui_select("rdisk", undef, \@rdisks),
                            $text{'view_removedesc'});
                }
+       if ($sparescnt>0) {
+               push(@grid, &ui_submit($text{'view_grow'}, "grow")." ".
+                           &ui_select("ndisk", undef, \@spares),
+                           $text{'view_growdesc'});
+               }
        }
 
 if ($raid->{'active'} && !$st[2]) {