+# $Header$
+
$afsbin="/moira/bin";
$vos="$afsbin/vos";
$pts="$afsbin/pts";
"CONTRIB", "contrib",
"COURSE", "course",
"HOMEDIR", "user",
+ "LEASE", "dept",
"PROJECT", "project",
"REF", "ref",
"SW", "sw",
"UROP", "urop",
);
-# Function: afs_vname
-# Returns the canonical volume name for (locker,type,cell)
-sub afs_vname
-{
- local($name,$type,$cell) = @_;
-
- $vtype = eval "\$vtypes_$cell{$type}";
- return "" unless $vtype;
-
- $vname = $vtype . "." . $name;
- $vname =~ s/[^-A-Za-z0-9_.]//g; # strip out illegal characters
- return $vname;
-}
-
-
# File format:
# cell server partition total used alloc
close(SRV);
}
-# Function: afs_find
-# Finds server/partition for allocation.
+# Find server/partition for allocation.
#
# Best fit algorithm used:
# max[ (2*free space) - (unused quota) ]
#
# Note: This routine does not actually adjust the quota; the caller
# should use afs_quota_adj();
+
sub afs_find
{
- local($cell,$type,$quota) = @_;
- local($i, $j, $vos, $a);
- local(@max) = '';
+ local($cell,$type,$quota,@except) = @_;
+ local($j,$k);
+ local(@max) = ("", "", -10000000);
&afs_lock;
chop(@afs_data);
- for $i ($[ .. $#afs_data) {
- ($a, $asrv, $apart, $t, $total, $used, $alloc) =
- split(/\s+/, $afs_data[$i]);
+ 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;
- if (! @max || $j > $max[2]) {
- ($total, $used) = &afs_partinfo($asrv, $apart, $cell);
- next if ($?);
- $afs_data[$i]=join(' ',$cell,$asrv,$apart,$t,$total,$used,$alloc);
- @max = ($asrv,$apart,$j);
- }
+ @max = ($asrv,$apart,$j) if (! @max || $j > $max[2]);
}
&afs_unlock;
return(@max);
}
-
-# Function: afs_quota_adj
-# Adjusts the quota allocation for a given server/partition
+#
+# Quota adjustments
+#
sub afs_quota_adj
{
local($cell,$asrv,$apart,$adj) = @_;
&afs_unlock;
return($found);
}
-
-
-sub afs_partinfo
-{
- local($as, $ap, $c) = @_;
- local(@vos, $total, $used);
-
- open(VOS,"$vos partinfo $as $ap -cell $c -noauth|");
- chop(@vos = <VOS>);
- close(VOS);
- return "" if ($?);
-
- @vos = split(/\s+/,$vos[0]);
- $total = pop(@vos);
- $used = $total-$vos[5];
- return ($total,$used);
-}