Commit 17578579 authored by Mike Hibler's avatar Mike Hibler

Try #2 to fix findSpareDisks. Add explicit "path" value to returned info.

The device name may not just be a simple concatenation of disk and
partition number (e.g., "cciss/c0d0" + "2" != "cciss/c0d0p2") so return
the full path string to use for operating on the device.
parent 671b70d8
...@@ -151,9 +151,12 @@ sub removePortForward($) { ...@@ -151,9 +151,12 @@ sub removePortForward($) {
# Yes, this means it's possible that we might steal partitions that are # Yes, this means it's possible that we might steal partitions that are
# in /etc/fstab by UUID -- oh well. # in /etc/fstab by UUID -- oh well.
# #
# This function returns a hash of device name => part number => size (bytes); # This function returns a hash of:
# note that a device name => size entry is filled IF the device has no # device name => part number => {size,path}
# partitions. # where size is in bytes and path is the full device name path to use
# (which may NOT just be a simple concatonation of device name and partition).
# Note that a device name => {size,fullpath} entry is filled IF the device
# has no partitions.
# #
sub findSpareDisks($) { sub findSpareDisks($) {
my ($minsize) = @_; my ($minsize) = @_;
...@@ -256,6 +259,7 @@ sub findSpareDisks($) { ...@@ -256,6 +259,7 @@ sub findSpareDisks($) {
# ignore the disk device. # ignore the disk device.
if (exists($retval{$dev}{"size"})) { if (exists($retval{$dev}{"size"})) {
delete $retval{$dev}{"size"}; delete $retval{$dev}{"size"};
delete $retval{$dev}{"path"};
if (scalar(keys(%{$retval{$dev}})) == 0) { if (scalar(keys(%{$retval{$dev}})) == 0) {
delete $retval{$dev}; delete $retval{$dev};
} }
...@@ -290,6 +294,7 @@ sub findSpareDisks($) { ...@@ -290,6 +294,7 @@ sub findSpareDisks($) {
} }
elsif ($output eq "0" && $size >= $minsize) { elsif ($output eq "0" && $size >= $minsize) {
$retval{$dev}{$part}{"size"} = $BLKSIZE * $size; $retval{$dev}{$part}{"size"} = $BLKSIZE * $size;
$retval{$dev}{$part}{"path"} = "/dev/$devpart";
} }
} }
} }
...@@ -299,6 +304,7 @@ isdisk: ...@@ -299,6 +304,7 @@ isdisk:
!defined($ftents{"/dev/$devpart"}) && !defined($ftents{"/dev/$devpart"}) &&
$size >= $minsize) { $size >= $minsize) {
$retval{$devpart}{"size"} = $BLKSIZE * $size; $retval{$devpart}{"size"} = $BLKSIZE * $size;
$retval{$devpart}{"path"} = "/dev/$devpart";
} }
} }
} }
......
...@@ -340,12 +340,12 @@ sub vz_rootPreConfig($) ...@@ -340,12 +340,12 @@ sub vz_rootPreConfig($)
my $totalSize = 0; my $totalSize = 0;
foreach my $dev (keys(%devs)) { foreach my $dev (keys(%devs)) {
if (defined($devs{$dev}{"size"})) { if (defined($devs{$dev}{"size"})) {
$blockdevs .= " /dev/$dev"; $blockdevs .= " " . $devs{$dev}{"path"};
$totalSize += $devs{$dev}{"size"}; $totalSize += $devs{$dev}{"size"};
} }
else { else {
foreach my $part (keys(%{$devs{$dev}})) { foreach my $part (keys(%{$devs{$dev}})) {
$blockdevs .= " /dev/${dev}${part}"; $blockdevs .= " " . $devs{$dev}{$part}{"path"};
$totalSize += $devs{$dev}{$part}{"size"}; $totalSize += $devs{$dev}{$part}{"size"};
} }
} }
......
...@@ -472,9 +472,14 @@ sub rootPreConfig($) ...@@ -472,9 +472,14 @@ sub rootPreConfig($)
# #
# Turn on write caching. Hacky. # Turn on write caching. Hacky.
# XXX note we do not use the returned "path" here as we need to
# change the setting on all devices, not just the whole disk devices.
# #
foreach my $dev (keys(%devs)) { foreach my $dev (keys(%devs)) {
mysystem2("hdparm -W1 /dev/$dev"); # only mess with the disks we are going to use
if (exists($devs{$dev}{"size"}) || $LVM_FULLDISKONLY == 0) {
mysystem2("hdparm -W1 /dev/$dev");
}
} }
# #
...@@ -493,12 +498,12 @@ sub rootPreConfig($) ...@@ -493,12 +498,12 @@ sub rootPreConfig($)
my $totalSize = 0; my $totalSize = 0;
foreach my $dev (keys(%devs)) { foreach my $dev (keys(%devs)) {
if (defined($devs{$dev}{"size"})) { if (defined($devs{$dev}{"size"})) {
$blockdevs .= " /dev/$dev"; $blockdevs .= " " . $devs{$dev}{"path"};
$totalSize += $devs{$dev}{"size"}; $totalSize += $devs{$dev}{"size"};
} }
elsif ($LVM_FULLDISKONLY == 0) { elsif ($LVM_FULLDISKONLY == 0) {
foreach my $part (keys(%{$devs{$dev}})) { foreach my $part (keys(%{$devs{$dev}})) {
$blockdevs .= " /dev/${dev}${part}"; $blockdevs .= " " . $devs{$dev}{$part}{"path"};
$totalSize += $devs{$dev}{$part}{"size"}; $totalSize += $devs{$dev}{$part}{"size"};
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment