From 97798f364af5e496e99d15740755d7f54fd3e944 Mon Sep 17 00:00:00 2001 From: probe Date: Fri, 29 Jan 1993 16:10:04 +0000 Subject: [PATCH] If a problem is encountered trying to create a volume on a server, fallback to trying the next best server. --- incremental/afs_create.pl | 16 +++++++++------- incremental/afs_utils.pl | 8 ++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/incremental/afs_create.pl b/incremental/afs_create.pl index e5a33f85..7a543cef 100644 --- a/incremental/afs_create.pl +++ b/incremental/afs_create.pl @@ -21,13 +21,15 @@ die "Cannot create $type volumes in $cell\n" unless $vtype; $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 diff --git a/incremental/afs_utils.pl b/incremental/afs_utils.pl index 1c97ecd1..ba1f8a14 100644 --- a/incremental/afs_utils.pl +++ b/incremental/afs_utils.pl @@ -68,16 +68,20 @@ sub afs_unlock 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]); -- 2.45.2