2001-01-15 05:01:19 +00:00
|
|
|
#! /bin/sh
|
2004-06-15 07:32:36 +00:00
|
|
|
# FS QA Test No. 050
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# Exercises basic XFS quota functionality
|
|
|
|
|
# MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
|
2004-07-30 05:28:14 +00:00
|
|
|
# options are: (-o) uquota, gquota, uqnoenforce, gqnoenforce
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
2002-06-04 23:07:56 +00:00
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
# under the terms of version 2 of the GNU General Public License as
|
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it would be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
#
|
|
|
|
|
# Further, this software is distributed without any warranty that it is
|
|
|
|
|
# free of the rightful claim of any third person regarding infringement
|
|
|
|
|
# or the like. Any license provided herein, whether implied or
|
|
|
|
|
# otherwise, applies only to this software file. Patent licenses, if
|
|
|
|
|
# any, provided herein do not apply to combinations of this program with
|
|
|
|
|
# other software, or any other product whatsoever.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write the Free Software Foundation, Inc., 59
|
|
|
|
|
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
|
|
#
|
|
|
|
|
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
|
|
|
|
# Mountain View, CA 94043, or:
|
|
|
|
|
#
|
|
|
|
|
# http://www.sgi.com
|
|
|
|
|
#
|
|
|
|
|
# For further information regarding this notice, see:
|
|
|
|
|
#
|
|
|
|
|
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# 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
|
2001-03-20 07:17:52 +00:00
|
|
|
. ./common.quota
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2004-06-15 07:32:36 +00:00
|
|
|
cd /
|
2001-03-20 07:17:52 +00:00
|
|
|
echo; echo "*** unmount"
|
|
|
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
|
|
|
rm -f $tmp.*
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
2004-06-15 07:32:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs xfs
|
2004-07-30 05:28:14 +00:00
|
|
|
_supported_os Linux IRIX
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2001-04-09 06:00:54 +00:00
|
|
|
rm -f $seq.out
|
|
|
|
|
cp /dev/null $seq.full
|
|
|
|
|
chmod a+rwx $seq.full # arbitrary users will write here
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
_require_scratch
|
2001-03-20 07:17:52 +00:00
|
|
|
_require_quota
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2004-07-30 05:28:14 +00:00
|
|
|
# setup a default run
|
|
|
|
|
if [ -z "$MOUNT_OPTIONS" ]; then
|
|
|
|
|
export MOUNT_OPTIONS="-o uquota"
|
|
|
|
|
fi
|
|
|
|
|
|
2002-06-04 06:52:25 +00:00
|
|
|
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
|
2003-05-22 04:16:45 +00:00
|
|
|
# (ie. blksize less than limit but not unduly less - ~85% is kind)
|
2002-06-04 06:52:25 +00:00
|
|
|
# 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;
|
|
|
|
|
}
|
2004-07-30 05:28:14 +00:00
|
|
|
' | _filter_repquota
|
2002-06-04 06:52:25 +00:00
|
|
|
}
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
2001-01-15 05:01:19 +00:00
|
|
|
cat $tmp.mkfs >>$seq.full
|
|
|
|
|
|
|
|
|
|
# keep the blocksize and data size for dd later
|
|
|
|
|
. $tmp.mkfs
|
|
|
|
|
|
2001-03-20 07:17:52 +00:00
|
|
|
_qmount
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2004-07-30 05:28:14 +00:00
|
|
|
# Irix uses filesystem name and Linux uses device of filesystem
|
|
|
|
|
if [ $HOSTOS = "Linux" ]; then
|
|
|
|
|
QUOTA_FS=$SCRATCH_DEV
|
|
|
|
|
else
|
|
|
|
|
QUOTA_FS=$SCRATCH_MNT
|
|
|
|
|
fi
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# setup exactly what it is we'll be testing
|
2002-06-04 06:52:25 +00:00
|
|
|
enforce=1
|
2001-03-20 02:17:03 +00:00
|
|
|
if src/feature -u $SCRATCH_DEV
|
2001-01-15 05:01:19 +00:00
|
|
|
then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=u ; eval `_choose_uid`; ln -s $seq.usrquota $seq.out
|
2001-01-15 05:01:19 +00:00
|
|
|
elif src/feature -g $SCRATCH_DEV
|
|
|
|
|
then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=g ; eval `_choose_gid`; ln -s $seq.grpquota $seq.out
|
2001-01-15 05:01:19 +00:00
|
|
|
elif src/feature -U $SCRATCH_DEV
|
|
|
|
|
then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=u ; eval `_choose_uid`; ln -s $seq.uqnoenforce $seq.out
|
2002-06-04 06:52:25 +00:00
|
|
|
enforce=0
|
2001-01-15 05:01:19 +00:00
|
|
|
elif src/feature -G $SCRATCH_DEV
|
|
|
|
|
then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=g ; eval `_choose_gid`; ln -s $seq.gqnoenforce $seq.out
|
2002-06-04 06:52:25 +00:00
|
|
|
enforce=0
|
2001-01-15 05:01:19 +00:00
|
|
|
else
|
|
|
|
|
_notrun "No quota support at mount time"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
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
|
2004-07-30 05:28:14 +00:00
|
|
|
_repquota -$type $QUOTA_FS | _filter_repquota
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "*** report initial settings" | tee -a $seq.full
|
2001-04-04 05:42:33 +00:00
|
|
|
_file_as_id $SCRATCH_MNT/initme $id $type 1024 0
|
2004-07-30 05:28:14 +00:00
|
|
|
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
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "*** push past the soft inode limit" | tee -a $seq.full
|
2001-04-04 05:42:33 +00:00
|
|
|
_file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
|
|
|
|
|
_file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
|
2001-03-20 07:17:52 +00:00
|
|
|
_qmount
|
2004-07-30 05:28:14 +00:00
|
|
|
_repquota -$type $QUOTA_FS | _filter_repquota
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "*** push past the soft block limit" | tee -a $seq.full
|
2001-04-04 05:42:33 +00:00
|
|
|
_file_as_id $SCRATCH_MNT/softie $id $type 1024 140
|
2001-03-20 07:17:52 +00:00
|
|
|
_qmount
|
2004-07-30 05:28:14 +00:00
|
|
|
_repquota -$type $QUOTA_FS | _filter_repquota
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo
|
2003-05-26 00:26:37 +00:00
|
|
|
# Note: for quota accounting (not enforcement), EDQUOT is not expected
|
|
|
|
|
echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
|
2001-01-15 05:01:19 +00:00
|
|
|
for i in 1 2 3 4 5 6 7 8 9 10 11 12
|
|
|
|
|
do
|
2001-04-04 05:42:33 +00:00
|
|
|
_file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
|
2001-01-15 05:01:19 +00:00
|
|
|
done
|
2001-03-20 07:17:52 +00:00
|
|
|
_qmount
|
2004-07-30 05:28:14 +00:00
|
|
|
_repquota -$type $QUOTA_FS | _filter_repquota
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo
|
2003-05-26 00:26:37 +00:00
|
|
|
# Note: for quota accounting (not enforcement), EDQUOT is not expected
|
|
|
|
|
echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
|
2001-04-04 05:42:33 +00:00
|
|
|
_file_as_id $SCRATCH_MNT/softie $id $type 1024 540
|
2004-07-30 05:28:14 +00:00
|
|
|
echo "ls -l $SCRATCH_MNT" >>$seq.full
|
|
|
|
|
ls -l $SCRATCH_MNT >>$seq.full
|
2001-03-20 07:17:52 +00:00
|
|
|
_qmount
|
2004-07-30 05:28:14 +00:00
|
|
|
_repquota -$type $QUOTA_FS | _filter_and_check_blocks
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|