[Fai-commit] r6319 - branches/experimental/patches
Michael Tautschnig
mt at alioth.debian.org
Wed Mar 16 12:41:54 UTC 2011
Author: mt
Date: 2011-03-16 12:41:47 +0000 (Wed, 16 Mar 2011)
New Revision: 6319
Modified:
branches/experimental/patches/setup-storage_deterministic-lv-ordering
branches/experimental/patches/setup-storage_internals-cleanup
branches/experimental/patches/setup-storage_lvm-raid-preserve
Log:
- fixed possibly uninitialized variable
- moved mdadm-startall to point right after parsing, just before checking for
existing volumes, added forced start of all examined RAID volumes
- added waits to mdadm --stop
Modified: branches/experimental/patches/setup-storage_deterministic-lv-ordering
===================================================================
--- branches/experimental/patches/setup-storage_deterministic-lv-ordering 2011-03-15 17:16:20 UTC (rev 6318)
+++ branches/experimental/patches/setup-storage_deterministic-lv-ordering 2011-03-16 12:41:47 UTC (rev 6319)
@@ -42,7 +42,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Commands.pm
+++ trunk/lib/setup-storage/Commands.pm
-@@ -522,7 +522,7 @@
+@@ -523,7 +523,7 @@
my $vg = $1; # the actual volume group
# now create or resize the configured logical volumes
Modified: branches/experimental/patches/setup-storage_internals-cleanup
===================================================================
--- branches/experimental/patches/setup-storage_internals-cleanup 2011-03-15 17:16:20 UTC (rev 6318)
+++ branches/experimental/patches/setup-storage_internals-cleanup 2011-03-16 12:41:47 UTC (rev 6319)
@@ -253,7 +253,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Volumes.pm
+++ trunk/lib/setup-storage/Volumes.pm
-@@ -572,10 +572,10 @@
+@@ -578,10 +578,10 @@
defined ($FAI::current_config{$1}) or die
"Can't preserve partition on $1 because $1 does not exist\n";
defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
Modified: branches/experimental/patches/setup-storage_lvm-raid-preserve
===================================================================
--- branches/experimental/patches/setup-storage_lvm-raid-preserve 2011-03-15 17:16:20 UTC (rev 6318)
+++ branches/experimental/patches/setup-storage_lvm-raid-preserve 2011-03-16 12:41:47 UTC (rev 6319)
@@ -6,9 +6,12 @@
* setup-storage/{Init,Parser,Volumes}.pm: Build device nesting tree.
* setup-storage/Commands.pm: Honor dependencies and nesting of LVM/RAID
devices when stopping and removing volumes and partitions.
- * setup-storage/Commands.pm: Add mdadm-startall call if arrays were detected
+ * setup-storage/Commands.pm: Add mdadm --assemble call if arrays were detected
by mdadm --examine (these might exist but haven't necessarily been started).
- * setup-storage: Added debug output of device nesting tree.
+ * setup-storage/Exec.pm: Ignore error exit code 2 in this mdadm --assemble
+ call.
+ * setup-storage: Force start of arrays using mdadm-startall. Added debug
+ output of device nesting tree.
Index: trunk/lib/setup-storage/Volumes.pm
===================================================================
@@ -66,7 +69,20 @@
}
}
-@@ -451,17 +467,19 @@
+@@ -442,29 +458,37 @@
+ # UUID=77a22e9f:83fd1276:135399f0:a895f15f
+ # devices=/dev/sde3,/dev/sdf3,/dev/sdd3
+
++ # create a temporary mdadm-from-examine.conf
++ open(MDADM_EX, ">$FAI::DATADIR/mdadm-from-examine.conf");
++
+ # the id of the RAID
+ my $id;
+
+ # parse the output line by line
+ foreach my $line (@mdadm_print) {
++ print MDADM_EX "$line";
+ if ($line =~ /^ARRAY \/dev\/md[\/]?(\d+)\s+/) {
$id = $1;
foreach (split (" ", $line)) {
@@ -93,7 +109,12 @@
undef($id);
}
}
-@@ -476,34 +494,49 @@
++
++ close(MDADM_EX);
+ }
+
+
+@@ -476,34 +500,49 @@
#
################################################################################
sub mark_preserve {
@@ -159,7 +180,7 @@
}
} else {
warn "Don't know how to mark $device_name for preserve\n";
-@@ -561,7 +594,7 @@
+@@ -561,7 +600,7 @@
"Can't preserve /dev/$1/$l because it does not exist\n";
defined ($FAI::configs{$config}{volumes}{$l}{size}{range}) or die
"Can't preserve /dev/$1/$l because it is not defined in the current config\n";
@@ -168,7 +189,7 @@
}
} elsif ($config eq "RAID") {
# check for volumes that need to be preserved and preserve the underlying
-@@ -575,7 +608,8 @@
+@@ -575,7 +614,8 @@
"Can't preserve /dev/md$r because it does not exist\n";
defined ($FAI::configs{$config}{volumes}{$r}{devices}) or die
"Can't preserve /dev/md$r because it is not defined in the current config\n";
@@ -182,26 +203,27 @@
===================================================================
--- trunk.orig/lib/setup-storage/Commands.pm
+++ trunk/lib/setup-storage/Commands.pm
-@@ -290,6 +290,18 @@
+@@ -290,6 +290,19 @@
################################################################################
sub build_raid_commands {
+ # check RAID arrays if there are pre-existing ones
-+ &FAI::push_command( "mdadm-startall", "", "mdadm_startall")
-+ if (scalar(keys %FAI::current_raid_config));
++ &FAI::push_command("mdadm --assemble --scan --config=$FAI::DATADIR/mdadm-from-examine.conf",
++ "", "mdadm_startall_examined") if (scalar(keys %FAI::current_raid_config));
+ foreach my $id (keys %FAI::current_raid_config) {
+ my $md = "/dev/md$id";
-+ my $pre_deps_cl = "mdadm_startall,self_cleared_" .
++ my $pre_deps_cl = "mdadm_startall_examined";
++ $pre_deps_cl .= ",self_cleared_" .
+ join(",self_cleared_", @{ $FAI::current_dev_children{$md} })
+ if (defined($FAI::current_dev_children{$md}) &&
+ scalar(@{ $FAI::current_dev_children{$md} }));
-+ &FAI::push_command( "mdadm --stop $md", "$pre_deps_cl", "self_cleared_$md");
++ &FAI::push_command( "mdadm --wait-clean -W --stop $md", "$pre_deps_cl", "self_cleared_$md");
+ }
+
foreach my $config (keys %FAI::configs) { # loop through all configs
# no encrypted, tmpfs, LVM or physical devices here
next if ($config eq "CRYPT" || $config eq "TMPFS" || $config =~ /^VG_./ || $config =~ /^PHY_./);
-@@ -346,7 +358,7 @@
+@@ -346,7 +359,7 @@
$pre_req =~ s/^,//;
# Assemble the array
&FAI::push_command(
@@ -210,7 +232,7 @@
"$pre_req", "exist_/dev/md$id");
# create the filesystem on the volume, if requested
-@@ -411,14 +423,14 @@
+@@ -411,14 +424,14 @@
# create all the devices
foreach my $d (keys %{ $FAI::configs{$config}{devices} }) {
$d = &FAI::enc_name($d);
@@ -228,7 +250,7 @@
$devs .= " $d";
$pre_dev .= ",pv_done_$d";
}
-@@ -463,14 +475,14 @@
+@@ -463,14 +476,14 @@
# create all the devices
foreach my $dev (@new_devices) {
@@ -246,7 +268,7 @@
$pre_dev .= ",pv_done_$dev";
}
$pre_dev =~ s/^,//;
-@@ -481,7 +493,7 @@
+@@ -481,7 +494,7 @@
&FAI::push_command( "vgextend $vg " . join (" ", @new_devices), "$pre_dev",
"vg_extended_$vg" );
} else {
@@ -255,7 +277,7 @@
}
# run vgreduce to get them removed
-@@ -607,11 +619,13 @@
+@@ -607,11 +620,13 @@
next;
} elsif ($dev =~ m{^/dev/md[\/]?(\d+)$}) {
my $vol = $1;
@@ -269,7 +291,7 @@
defined($FAI::configs{"VG_$ivg"}{volumes}{$lv}) or next;
next if (1 == $FAI::configs{"VG_$ivg"}{volumes}{$lv}{size}{preserve});
} else {
-@@ -623,26 +637,35 @@
+@@ -623,26 +638,35 @@
}
if (0 == $clear_vg) {
@@ -310,7 +332,7 @@
(keys %{ $FAI::current_lvm_config{$vg}{volumes} });
}
&FAI::push_command("true", $vg_setup_pre, "vg_exists_$vg");
-@@ -650,9 +673,16 @@
+@@ -650,9 +674,16 @@
return 0;
}
@@ -329,7 +351,7 @@
$vg_destroy_pre .= ",lv_rm_$vg/$lv";
}
&FAI::push_command( "vgremove $vg", "$vg_destroy_pre", "vg_removed_$vg");
-@@ -662,7 +692,7 @@
+@@ -662,7 +693,7 @@
$devices .= " " . &FAI::enc_name($_) foreach
(@{ $FAI::current_lvm_config{$vg}{physical_volumes} });
$FAI::debug and print "Erased devices:$devices\n";
@@ -338,7 +360,7 @@
return 1;
}
-@@ -676,14 +706,26 @@
+@@ -676,14 +707,26 @@
sub build_lvm_commands {
# disable volumes if there are pre-existing ones
@@ -372,7 +394,7 @@
# loop through all configs
foreach my $config (keys %FAI::configs) {
-@@ -913,8 +955,15 @@
+@@ -913,8 +956,15 @@
or die "Can't change disklabel, partitions are to be preserved\n";
# write the disklabel to drop the previous partition table
@@ -393,8 +415,24 @@
===================================================================
--- trunk.orig/bin/setup-storage
+++ trunk/bin/setup-storage
-@@ -170,6 +170,11 @@
+@@ -137,6 +137,15 @@
+ # make sure there are no empty disk_config stanzas
+ &FAI::check_config;
++# first find the proper way to tell udev to settle
++$FAI::udev_settle = "udevadm settle --timeout=10" if (&FAI::in_path("udevadm"));
++$FAI::udev_settle = "udevsettle --timeout=10" if (&FAI::in_path("udevsettle"));
++defined($FAI::udev_settle) or die "Failed to find determine a proper way to tell udev to settle; is udev installed?";
++
++# start all RAID arrays in case some of the aren't running yet
++`mdadm-startall`;
++`$FAI::udev_settle`;
++
+ # read the sizes and partition tables of all disks listed in $FAI::disks
+ &FAI::get_current_disks;
+
+@@ -170,6 +179,11 @@
+
our %current_raid_config;
print Dumper \%current_raid_config;
+
@@ -405,7 +443,7 @@
}
# compute the new LVM and partition sizes; do the partition sizes first to have
-@@ -180,6 +185,8 @@
+@@ -180,6 +194,8 @@
# print the current contents of $FAI::configs
$FAI::debug and print "Desired disk layout\n";
$FAI::debug and print Dumper \%FAI::configs;
@@ -414,6 +452,17 @@
# generate the command script
&FAI::build_disk_commands;
+@@ -200,10 +216,6 @@
+ }
+
+ # run the commands (if $FAI::no_dry_run is set)
+-# first find the proper way to tell udev to settle
+-$FAI::udev_settle = "udevadm settle --timeout=10" if (&FAI::in_path("udevadm"));
+-$FAI::udev_settle = "udevsettle --timeout=10" if (&FAI::in_path("udevsettle"));
+-defined($FAI::udev_settle) or die "Failed to find determine a proper way to tell udev to settle; is udev installed?";
+ foreach (&numsort(keys %FAI::commands)) {
+ `$FAI::udev_settle`;
+ next if ($FAI::commands{$_}{cmd} eq "true");
Index: trunk/lib/setup-storage/Init.pm
===================================================================
--- trunk.orig/lib/setup-storage/Init.pm
@@ -622,3 +671,23 @@
($this_mp eq "none") or $all_mount_pts{$this_mp} = 1;
}
} elsif ($config eq "CRYPT") {
+Index: trunk/lib/setup-storage/Exec.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Exec.pm
++++ trunk/lib/setup-storage/Exec.pm
+@@ -178,6 +178,15 @@
+ exit_codes => [0..255],
+ },
+ {
++ error => "mdadm_assemble",
++ message => "mdadm tried to assemble arrays but failed, ignoring as arrays might be running already\n",
++ stderr_regex => '^$',
++ stdout_regex => '^$',
++ program => "mdadm --assemble --scan --config=$FAI::DATADIR/mdadm-from-examine.conf",
++ response => "warn",
++ exit_codes => [2],
++ },
++ {
+ error => "catch_all_nonzero_exit_code",
+ message => "Command had non-zero exit code\n",
+ stderr_regex => "",
More information about the Fai-commit
mailing list