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
|
2006-05-18 15:48:26 +00:00
|
|
|
# uquota, gquota, uqnoenforce, gqnoenforce, pquota, pqnoenforce
|
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
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# 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
|
|
|
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
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
|
2001-04-09 06:00:54 +00:00
|
|
|
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
|
|
|
|
2005-12-14 05:04:52 +00:00
|
|
|
bsoft=100
|
|
|
|
|
bhard=500
|
|
|
|
|
isoft=4
|
|
|
|
|
ihard=10
|
|
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
|
2005-12-14 05:04:52 +00:00
|
|
|
_filter_report()
|
|
|
|
|
{
|
|
|
|
|
tr -s '[:space:]' | sed -e "s/^\#$id /[NAME] /g" -e "s/^#0 /[ROOT] /g"
|
|
|
|
|
}
|
2002-06-04 06:52:25 +00:00
|
|
|
|
|
|
|
|
# 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.
|
2005-12-09 02:52:22 +00:00
|
|
|
#
|
2005-12-14 05:04:52 +00:00
|
|
|
_filter_and_check_blks()
|
2002-06-04 06:52:25 +00:00
|
|
|
{
|
|
|
|
|
perl -npe '
|
2005-12-14 05:04:52 +00:00
|
|
|
if (/^\#'$id'\s+(\d+)/ && '$enforce') {
|
|
|
|
|
$maximum = '$bhard';
|
|
|
|
|
$minimum = '$bhard' * 85/100;
|
|
|
|
|
if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
|
|
|
|
|
printf(" URK %d: %d is out of range! [%d,%d]\n",
|
|
|
|
|
'$id', $1, $minimum, $maximum);
|
2002-06-04 06:52:25 +00:00
|
|
|
}
|
2005-12-14 05:04:52 +00:00
|
|
|
s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
|
2002-06-04 06:52:25 +00:00
|
|
|
}
|
2005-12-14 05:04:52 +00:00
|
|
|
' | _filter_report
|
2002-06-04 06:52:25 +00:00
|
|
|
}
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
_exercise()
|
|
|
|
|
{
|
|
|
|
|
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
|
|
|
|
cat $tmp.mkfs >>$seq.full
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
# keep the blocksize and data size for dd later
|
|
|
|
|
. $tmp.mkfs
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
_qmount
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
# Figure out whether we're doing large allocations
|
|
|
|
|
# (bail out if they're so large they stuff the test up)
|
|
|
|
|
_test_inode_flag extsz-inherit $SCRATCH_MNT
|
|
|
|
|
noextsz=$?
|
|
|
|
|
extsize=`_test_inode_extsz $SCRATCH_MNT`
|
|
|
|
|
[ $extsize -ge 512000 ] && \
|
|
|
|
|
_notrun "Extent size hint is too large ($extsize bytes)"
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
_qsetup
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
|
|
|
|
|
echo "and using type=$type id=$id" >>$seq.full
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
echo
|
|
|
|
|
echo "*** report no quota settings" | tee -a $seq.full
|
|
|
|
|
xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
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
|
|
|
|
|
xfs_quota -D $tmp.projects -P $temp.projid -x \
|
|
|
|
|
-c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
|
|
|
|
|
-c "limit -$type isoft=$isoft ihard=$ihard $id" \
|
|
|
|
|
$SCRATCH_DEV
|
|
|
|
|
xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
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
|
|
|
|
|
xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
|
2006-05-25 06:13:27 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
echo
|
|
|
|
|
echo "*** push past the soft block limit" | tee -a $seq.full
|
|
|
|
|
_file_as_id $SCRATCH_MNT/softie $id $type 1024 140
|
|
|
|
|
_qmount
|
|
|
|
|
xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
|
2006-05-25 06:13:27 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
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
|
|
|
|
|
xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
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
|
|
|
|
|
xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_and_check_blks
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2006-05-18 15:48:26 +00:00
|
|
|
echo
|
|
|
|
|
echo "*** unmount"
|
|
|
|
|
umount $SCRATCH_MNT
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ensures only one quota mount option is specified
|
|
|
|
|
_qmount_option()
|
|
|
|
|
{
|
|
|
|
|
#replace any user defined quota options
|
|
|
|
|
export MOUNT_OPTIONS=`echo $MOUNT_OPTIONS \
|
|
|
|
|
| sed -e 's/uquota/$q_opt/g' \
|
|
|
|
|
-e 's/gquota/$q_opt/g' \
|
|
|
|
|
-e 's/pquota/$q_opt/g' \
|
|
|
|
|
-e 's/quota/$q_opt/g' \
|
|
|
|
|
-e 's/uqnoenforce/$q_opt/g' \
|
|
|
|
|
-e 's/gqnoenforce/$q_opt/g' \
|
|
|
|
|
-e 's/pqnoenforce/$q_opt/g' \
|
|
|
|
|
-e 's/qnoenforce/$q_opt/g' \
|
|
|
|
|
| sed 's/$q_opt/'$1'/g'`
|
|
|
|
|
|
|
|
|
|
#check $q_opt is in new mount options
|
|
|
|
|
echo $MOUNT_OPTIONS | grep "$1" > /dev/null 2>&1
|
|
|
|
|
[ "$?" -eq 0 ] || export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $1"
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-25 06:13:27 +00:00
|
|
|
cat >$tmp.projects <<EOF
|
|
|
|
|
1:$SCRATCH_MNT
|
2006-05-18 15:48:26 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat >$tmp.projid <<EOF
|
|
|
|
|
root:0
|
|
|
|
|
scrach:1
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
projid_file="$tmp.projid"
|
|
|
|
|
|
|
|
|
|
echo "*** user"
|
|
|
|
|
if [ "$HOSTOS" == "IRIX" ]
|
|
|
|
|
then
|
|
|
|
|
_qmount_option "quota"
|
|
|
|
|
else
|
|
|
|
|
_qmount_option "uquota"
|
|
|
|
|
fi
|
|
|
|
|
_exercise
|
|
|
|
|
|
|
|
|
|
echo "*** group"
|
|
|
|
|
_qmount_option "gquota"
|
|
|
|
|
_exercise
|
|
|
|
|
|
2006-05-25 06:13:27 +00:00
|
|
|
echo "*** uqnoenforce"
|
2006-05-18 15:48:26 +00:00
|
|
|
if [ "$HOSTOS" == "IRIX" ]
|
|
|
|
|
then
|
|
|
|
|
_qmount_option "qnoenforce"
|
|
|
|
|
else
|
|
|
|
|
_qmount_option "uqnoenforce"
|
|
|
|
|
fi
|
|
|
|
|
_exercise
|
|
|
|
|
|
2006-05-25 06:13:27 +00:00
|
|
|
echo "*** gqnoenforce"
|
2006-05-18 15:48:26 +00:00
|
|
|
_qmount_option "gqnoenforce"
|
|
|
|
|
_exercise
|
|
|
|
|
|
2006-05-25 06:13:27 +00:00
|
|
|
echo "*** pquota"
|
2006-05-18 15:48:26 +00:00
|
|
|
_qmount_option "pquota"
|
|
|
|
|
_exercise
|
|
|
|
|
|
2006-05-25 06:13:27 +00:00
|
|
|
echo "*** pqnoenforce"
|
2006-05-18 15:48:26 +00:00
|
|
|
_qmount_option "pqnoenforce"
|
|
|
|
|
_exercise
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|