$vname = $vtype . "." . $locker;
$vname =~ s/[^-A-Za-z0-9_.]//g; # strip out illegal characters
-# Find free space
-($asrv,$apart) = &afs_find($cell,$type,$quota);
-die "Unable to find space to create $vname in $cell\n" unless ($asrv&&$apart);
-
-# Create volume
-system("$vos create $asrv $apart $vname -cell $cell >/dev/null") &&
- &fatal("Unable to create $vname in $cell");
+# Find free space/Create volume
+foreach $tries (1..3) {
+ ($asrv,$apart) = &afs_find($cell,$type,$quota,@except);
+ die "Unable to find space to create $vname in $cell\n" unless ($asrv&&$apart);
+ $code = system("$vos create $asrv $apart $vname -cell $cell >/dev/null");
+ push(@except, $asrv);
+ next if ($code);
+}
+&fatal("Unable to create $vname in $cell") if ($code); # Too many create errors
push(@clean, "$vos remove $asrv $apart $vname -cell $cell >/dev/null");
# Create mountpoint and set quota
sub afs_find
{
- local($cell,$type,$quota) = @_;
- local($j);
+ local($cell,$type,$quota,@except) = @_;
+ local($j,$k);
local(@max) = '';
&afs_lock;
chop(@afs_data);
+ sloop:
for (@afs_data) {
local ($a, $asrv, $apart, $t, $total, $used, $alloc) = split(/\s+/,$_);
next if ($a ne $cell || !$total || $type !~ /$t/);
+ for $j (@except) {
+ next sloop if ($j eq $asrv);
+ }
$alloc = $used if ($alloc < $used);
$j = 2*$total - $used - $alloc;
@max = ($asrv,$apart,$j) if (! @max || $j > $max[2]);