File: [Development] / xfs-cmds / xfstests / 050 (download)
Revision 1.23, Wed Nov 9 02:49:08 2005 UTC (11 years, 11 months ago) by nathans.longdrop.melbourne.sgi.com
Branch: MAIN
Changes since 1.22: +0 -28
lines
Update copyright annotations and license boilerplates to correspond with SGI Legals preferences.
Merge of master-melb:xfs-cmds:24327a by kenmcd.
|
#! /bin/sh
# FS QA Test No. 050
#
# Exercises basic XFS quota functionality
# MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
# options are: (-o) uquota, gquota, uqnoenforce, gqnoenforce
#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
#-----------------------------------------------------------------------
#
# creator
owner=nathans@sgi.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.quota
_cleanup()
{
cd /
echo; echo "*** unmount"
umount $SCRATCH_MNT 2>/dev/null
rm -f $tmp.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# real QA test starts here
_supported_fs xfs
_supported_os Linux IRIX
rm -f $seq.out
cp /dev/null $seq.full
chmod a+rwx $seq.full # arbitrary users will write here
_require_scratch
_require_quota
# setup a default run
[ -z "$MOUNT_OPTIONS" ] && export MOUNT_OPTIONS="-o uquota"
blksoft=100
blkhard=500
inosoft=4
inohard=10
# The actual point at which limit enforcement takes place for the
# hard block limit is variable depending on filesystem blocksize,
# and iosize. What we want to test is that the limit is enforced
# (ie. blksize less than limit but not unduly less - ~85% is kind)
# nowadays we actually get much closer to the limit before EDQUOT.
#
_filter_and_check_blocks()
{
perl -npe '
if (/^'$name'\s+([-|+]){2}\s+(\d+)/ && '$enforce') {
$maximum = '$blkhard';
$minimum = '$blkhard' * 85/100;
if ($2 < $minimum || $2 > $maximum) {
printf(" URK - %d is out of range! [%d,%d] \n",
$2, $minimum, $maximum);
}
s/^('$name'\s+[-|+][-|+]\s+)(\d+)/\1 OK/g;
}
' | _filter_repquota
}
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
cat $tmp.mkfs >>$seq.full
# keep the blocksize and data size for dd later
. $tmp.mkfs
_qmount
# Irix uses filesystem name and Linux uses device of filesystem
if [ $HOSTOS = "Linux" ]; then
QUOTA_FS=$SCRATCH_DEV
else
QUOTA_FS=$SCRATCH_MNT
fi
_qsetup
echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
echo "and using type=$type id=$id" >>$seq.full
echo
echo "*** report no quota settings" | tee -a $seq.full
_repquota -$type $QUOTA_FS | _filter_repquota
echo
echo "*** report initial settings" | tee -a $seq.full
_file_as_id $SCRATCH_MNT/initme $id $type 1024 0
echo "ls -l $SCRATCH_MNT" >>$seq.full
ls -l $SCRATCH_MNT >>$seq.full
_setquota -$type $id $blksoft $blkhard $inosoft $inohard $QUOTA_FS
_repquota -$type $QUOTA_FS | _filter_repquota
echo
echo "*** push past the soft inode limit" | tee -a $seq.full
_file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
_file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
_qmount
_repquota -$type $QUOTA_FS | _filter_repquota
echo
echo "*** push past the soft block limit" | tee -a $seq.full
_file_as_id $SCRATCH_MNT/softie $id $type 1024 140
_qmount
_repquota -$type $QUOTA_FS | _filter_repquota
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
for i in 1 2 3 4 5 6 7 8 9 10 11 12
do
_file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
done
_qmount
_repquota -$type $QUOTA_FS | _filter_repquota
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
_file_as_id $SCRATCH_MNT/softie $id $type 1024 540
echo "ls -l $SCRATCH_MNT" >>$seq.full
ls -l $SCRATCH_MNT >>$seq.full
_qmount
_repquota -$type $QUOTA_FS | _filter_and_check_blocks
# success, all done
status=0
exit