2 # Usage: afs_quota path quota
4 require "/moira/bin/afs_utils.pl";
6 die "Usage: $0 path quota\n" unless (@ARGV==2);
9 $path =~ s:^/afs/([^.]):/afs/.\1:;
11 system("$fs checkb >/dev/null");
13 open(PROG,"$fs lv $path|");
16 die "Unable to get information about $path\n" if ($?);
19 @tmp = split(/\s+/, shift(@fs));
21 @tmp = split(/\s+/, shift(@fs));
23 print "$vname $oldq $newq\n";
25 open(PROG,"$fs whichcell $path|");
28 die "Unable to get information about $path\n" if ($?);
31 ($cell=pop(@tmp)) =~ s/^'(.*)'$/\1/;
34 open(PROG,"$vos ex $vname -cell $cell|");
37 die "Unable to get volume information about $vname ($path)\n" if ($?);
40 ($vusage, $vusage, $vusage, $vusage) = split(/\s+/,$_);
42 ($asrv,$asrv,$apart) = split(/\s+/,$_);
44 open(PROG,"$vos partinfo $asrv $apart -cell $cell|");
47 die "Unable to get partition information about $asrv $apart\n" if ($?);
49 @tmp = split(/\s+/,$_);
51 $dusage = $dtotal - $tmp[5];
53 system("$fs","sq",$path,$newq);
54 die "Unable to change quota on $path\n" if ($?);
56 &afs_quota_adj($cell,$asrv,$apart,$newq-$oldq,$dusage);
58 if ($dusage > (0.9 * $dtotal)) {
59 system("$zwrite","-q","-n","-c","afsadm","-i","moira","-m",
60 "WARNING: Disk usage on $asrv:$apart is greater than 90%
61 Used $dusage K out of $dtotal K");
63 elsif (($dusage + ($newq-$vusage)) > (0.9 * $dtotal)) {
64 system("$zwrite","-q","-n","-c","afsadm","-i","moira","-m",
65 "Quota change on volume $vname, if used completely will cause
66 $asrv:$apart to be over 90% used.
68 Current volume usage: $vusage, old quota $oldq, new quota $newq");
70 elsif ($newq-$oldq > 3999999) {
71 system("$zwrite","-q","-n","-c","afsadm","-i","moira","-m",
72 "Increased quota on volume $vname ($asrv:$apart) from $oldq to $newq");