[Fai-commit] r3540 - people/mugwump/lvmraid/bin
fai-commit at lists.alioth.debian.org
fai-commit at lists.alioth.debian.org
Mon Jul 10 05:15:34 UTC 2006
Author: samv-guest
Date: 2006-07-10 05:15:33 +0000 (Mon, 10 Jul 2006)
New Revision: 3540
Modified:
people/mugwump/lvmraid/bin/
people/mugwump/lvmraid/bin/setup_harddisks
Log:
Use mdadm, not raidtools.
I guess tools have changed between woody and sarge :)
Property changes on: people/mugwump/lvmraid/bin
___________________________________________________________________
Name: svk:merge
+ d29f7b36-84ff-0310-85ce-ba787dbd31ca:/local/fai/people/mugwump/lvmraid/bin:10514
Modified: people/mugwump/lvmraid/bin/setup_harddisks
===================================================================
--- people/mugwump/lvmraid/bin/setup_harddisks 2006-07-10 03:10:43 UTC (rev 3539)
+++ people/mugwump/lvmraid/bin/setup_harddisks 2006-07-10 05:15:33 UTC (rev 3540)
@@ -56,9 +56,9 @@
To set up LVM managed areas
-=item L<mkraid(8)>
+=item L<mdadm(8)>
-To set up Linux md-utils managed spaces.
+To set up Linux mdadm managed spaces.
=back
@@ -1436,7 +1436,7 @@
$count = @devices;
foreach (@devices) {
say("stopping $_");
- if (!run("raidstop $_",1)) {
+ if (!run("mdadm --manage --stop $_",1)) {
say("defering $_ (rc=$?)");
push @failed, $_;
}
@@ -1445,8 +1445,6 @@
barf("Could not stop raid devices: @failed")
if @failed;
-
-
}
use IO::Handle;
@@ -1479,30 +1477,41 @@
sub DoDeepRAIDnLVMmagic {
my $raid10_start;
+ my @mdadm_commands;
if (my @md = sort { $a <=> $b } keys %g_md) {
- open RAIDTAB, ">$ENV{LOGDIR}/raidtab" or die $!;
- print RAIDTAB RaidTabEntry($_) foreach @md;
+ push @mdadm_commands, [MdAdmCommand($_)] foreach @md;
- $raid10_start = pop (@md) + 1;
+ # FIXME - this needs testing.
+ $raid10_start = scalar(@md);
if (my (@raid10) = (sort { $a <=> $b }
grep { $_ >= $raid10_start }
keys %g_md)) {
- print RAIDTAB RaidTabEntry($_) foreach @raid10;
+ push @mdadm_commands, [MdAdmCommand($_)] foreach @raid10;
} else {
$raid10_start = undef;
}
- close RAIDTAB;
-
}
if ($test) {
- say ("raid tab:");
- #system("cat $ENV{LOGDIR}/raidtab");
+ say ("mdadm commands:");
+ print " @$_\n" foreach @mdadm_commands;
}
+ my $run_mdadm = sub {
+ my $device = "/dev/".(shift);
+ my $i;
+ for ($i = 0; $i < @mdadm_commands; $i++) {
+ last if ($mdadm_commands[$i][2] eq $device);
+ }
+ die if $i == @mdadm_commands;
+ run(join(" ",@{$mdadm_commands[$i]}));
+ @mdadm_commands = (@mdadm_commands[0..$i-1],
+ @mdadm_commands[$i+1..$#mdadm_commands]);
+ };
+
my $n;
if ($raid10_start) {
$n = $raid10_start;
@@ -1511,8 +1520,7 @@
say("Zap'ing partitions: @{$g_md{$n}->{members}}");
zapDev("/dev/$_") foreach @{$g_md{$n}->{members}};
}
- run("mkraid --configfile $ENV{LOGDIR}/raidtab "
- ."/dev/md$n");
+ $run_mdadm->("md$n");
$n++;
}
}
@@ -1524,8 +1532,7 @@
say("Zap'ing partitions: @{$g_md{$n}->{members}}");
zapDev("/dev/$_") foreach @{$g_md{$n}->{members}};
}
- run("mkraid --configfile $ENV{LOGDIR}/raidtab "
- ."/dev/md$n");
+ $run_mdadm->("md$n");
# re-configure the device, etc
if (my $mountpoint = $g_md{$n}->{mountpoint}) {
@@ -1535,6 +1542,10 @@
$n++
}
+ die "Extra mdadm commands that we didn't issue:\n"
+ .join("\n",map { " @$_" } @mdadm_commands)
+ if @mdadm_commands;
+
my $vgs = [];
while (my $vg = each %g_DiskMountpoints) {
my $vg_entry;
@@ -1607,18 +1618,16 @@
}
}
-sub RaidTabEntry {
+sub MdAdmCommand {
my $dev = shift;
my $x = $g_md{$dev};
- my $entry = "raiddev /dev/md$dev\n";
- my $aii = sub { $entry .= sprintf " %-24s %s\n", @_ };
+ my @command = (qw(mdadm -C), "/dev/md$dev");
- $aii->("raid-level", $x->{level});
- $aii->("chunk-size", (4<<($x->{chunk_factor}||=8)));
- $aii->("persistent-superblock", "1");
+ push @command, "--level", $x->{level};
+ push @command, "--chunk", (4<<($x->{chunk_factor}||=10))>>10;
- # RAID 10 is a special case
+ # manual RAID 10 (setting up raid 1 disks, then raid 0'ing them)
if ($x->{sidea}) {
my @sides = map { $x->{"side$_"} || () } ("a".."z");
@@ -1642,15 +1651,14 @@
}
- $aii->("nr-raid-disks", scalar(@{$x->{members}}));
+ push @command, "--raid-devices", scalar(@{$x->{members}});
my $num = 0;
for my $device (sort @{$x->{members}}) {
- $aii->("device", "/dev/$device");
- $aii->("raid-disk", $num++);
+ push @command, "/dev/$device";
}
- return $entry;
+ return @command;
}
More information about the Fai-commit
mailing list