All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

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($) {
# Yes, this means it's possible that we might steal partitions that are
# in /etc/fstab by UUID -- oh well.
#
# This function returns a hash of device name => part number => size (bytes);
# note that a device name => size entry is filled IF the device has no
# partitions.
# This function returns a hash of:
# device name => part number => {size,path}
# 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($) {
my ($minsize) = @_;
......@@ -256,6 +259,7 @@ sub findSpareDisks($) {
# ignore the disk device.
if (exists($retval{$dev}{"size"})) {
delete $retval{$dev}{"size"};
delete $retval{$dev}{"path"};
if (scalar(keys(%{$retval{$dev}})) == 0) {
delete $retval{$dev};
}
......@@ -290,6 +294,7 @@ sub findSpareDisks($) {
}
elsif ($output eq "0" && $size >= $minsize) {
$retval{$dev}{$part}{"size"} = $BLKSIZE * $size;
$retval{$dev}{$part}{"path"} = "/dev/$devpart";
}
}
}
......@@ -299,6 +304,7 @@ isdisk:
!defined($ftents{"/dev/$devpart"}) &&
$size >= $minsize) {
$retval{$devpart}{"size"} = $BLKSIZE * $size;
$retval{$devpart}{"path"} = "/dev/$devpart";
}
}
}
......
......@@ -340,12 +340,12 @@ sub vz_rootPreConfig($)
my $totalSize = 0;
foreach my $dev (keys(%devs)) {
if (defined($devs{$dev}{"size"})) {
$blockdevs .= " /dev/$dev";
$blockdevs .= " " . $devs{$dev}{"path"};
$totalSize += $devs{$dev}{"size"};
}
else {
foreach my $part (keys(%{$devs{$dev}})) {
$blockdevs .= " /dev/${dev}${part}";
$blockdevs .= " " . $devs{$dev}{$part}{"path"};
$totalSize += $devs{$dev}{$part}{"size"};
}
}
......
......@@ -472,9 +472,14 @@ sub rootPreConfig($)
#
# 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)) {
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($)
my $totalSize = 0;
foreach my $dev (keys(%devs)) {
if (defined($devs{$dev}{"size"})) {
$blockdevs .= " /dev/$dev";
$blockdevs .= " " . $devs{$dev}{"path"};
$totalSize += $devs{$dev}{"size"};
}
elsif ($LVM_FULLDISKONLY == 0) {
foreach my $part (keys(%{$devs{$dev}})) {
$blockdevs .= " /dev/${dev}${part}";
$blockdevs .= " " . $devs{$dev}{$part}{"path"};
$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