mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
4f4737df70
xfs/299 and xfs/050 share the same function to filter quota reporting into a format suitable for the golden output. Refactor this so that we can use it in a new test. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
231 lines
5.9 KiB
Bash
Executable File
231 lines
5.9 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
|
#
|
|
# FS QA Test No. 299
|
|
#
|
|
# Exercises basic XFS quota functionality, with all 3 quotas together
|
|
# uquota, gquota, pquota
|
|
# uqnoenforce, gqnoenforce, pqnoenforce
|
|
#
|
|
seq=`basename $0`
|
|
seqres=$RESULT_DIR/$seq
|
|
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 /
|
|
_scratch_unmount 2>/dev/null
|
|
rm -f $tmp.*
|
|
}
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
# real QA test starts here
|
|
_supported_fs xfs
|
|
|
|
cp /dev/null $seqres.full
|
|
chmod a+rwx $seqres.full # arbitrary users will write here
|
|
|
|
_require_scratch
|
|
_require_xfs_quota
|
|
_require_xfs_mkfs_crc
|
|
_require_xfs_crc
|
|
|
|
# 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_blks()
|
|
{
|
|
perl -npe '
|
|
if (/^\#'$id'\s+(\d+)/ && '$enforce') {
|
|
$maximum = '$bhard';
|
|
$minimum = '$bhard' * 85/100;
|
|
$used = $1 * 1024;
|
|
if (($used < $minimum || $used > $maximum) && '$noextsz') {
|
|
printf(" URK %d: %d is out of range! [%d,%d]\n",
|
|
'$id', $used, $minimum, $maximum);
|
|
}
|
|
s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
|
|
}
|
|
' | _filter_quota_report
|
|
}
|
|
|
|
_qsetup()
|
|
{
|
|
opt=$1
|
|
enforce=0
|
|
if [ $opt = "u" -o $opt = "uno" ]; then
|
|
type=u
|
|
eval `_choose_uid`
|
|
elif [ $opt = "g" -o $opt = "gno" ]; then
|
|
type=g
|
|
eval `_choose_gid`
|
|
elif [ $opt = "p" -o $opt = "pno" ]; then
|
|
type=p
|
|
eval `_choose_prid`
|
|
fi
|
|
[ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
|
|
|
|
echo "Using type=$type id=$id" >> $seqres.full
|
|
}
|
|
|
|
_exercise()
|
|
{
|
|
|
|
# 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)"
|
|
|
|
_qsetup $1
|
|
|
|
echo "Using type=$type id=$id" >>$seqres.full
|
|
|
|
$XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
|
|
|
|
echo
|
|
echo "*** report no quota settings" | tee -a $seqres.full
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "repquota -birnN -$type" $SCRATCH_DEV |
|
|
_filter_quota_report | LC_COLLATE=POSIX sort -ru
|
|
|
|
echo
|
|
echo "*** report initial settings" | tee -a $seqres.full
|
|
_file_as_id $SCRATCH_MNT/initme $id $type 1024 0
|
|
echo "ls -l $SCRATCH_MNT" >>$seqres.full
|
|
ls -l $SCRATCH_MNT >>$seqres.full
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
|
|
-c "limit -$type isoft=$isoft ihard=$ihard $id" \
|
|
$SCRATCH_DEV
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "repquota -birnN -$type" $SCRATCH_DEV |
|
|
_filter_quota_report | LC_COLLATE=POSIX sort -ru
|
|
|
|
echo
|
|
echo "*** push past the soft inode limit" | tee -a $seqres.full
|
|
_file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
|
|
_file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
|
|
_file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
|
|
_file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
|
|
_qmount
|
|
$XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "repquota -birnN -$type" $SCRATCH_DEV |
|
|
_filter_quota_report | LC_COLLATE=POSIX sort -ru
|
|
|
|
echo
|
|
echo "*** push past the soft block limit" | tee -a $seqres.full
|
|
_file_as_id $SCRATCH_MNT/softie $id $type $bsize 200
|
|
_qmount
|
|
$XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
|
|
-c "warn -b -$type 0 $id" $SCRATCH_DEV
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "repquota -birnN -$type" $SCRATCH_DEV |
|
|
_filter_quota_report | LC_COLLATE=POSIX sort -ru
|
|
|
|
echo
|
|
# Note: for quota accounting (not enforcement), EDQUOT is not expected
|
|
echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.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_PROG -x -c "warn -b -$type 0 $id" \
|
|
-c "warn -i -$type 0 $id" $SCRATCH_DEV
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "repquota -birnN -$type" $SCRATCH_DEV |
|
|
_filter_quota_report | LC_COLLATE=POSIX sort -ru
|
|
|
|
echo
|
|
# Note: for quota accounting (not enforcement), EDQUOT is not expected
|
|
echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
|
|
_file_as_id $SCRATCH_MNT/softie $id $type $bsize 600
|
|
echo "ls -l $SCRATCH_MNT" >>$seqres.full
|
|
ls -l $SCRATCH_MNT >>$seqres.full
|
|
_qmount
|
|
$XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
|
|
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
|
|
-c "repquota -birnN -$type" $SCRATCH_DEV |
|
|
_filter_and_check_blks | LC_COLLATE=POSIX sort -ru
|
|
|
|
echo
|
|
|
|
# clean up our files so we don't pollute the next run
|
|
rm -f $SCRATCH_MNT/*
|
|
|
|
}
|
|
|
|
_scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
|
|
cat $tmp.mkfs >>$seqres.full
|
|
# keep the blocksize and data size for dd later
|
|
. $tmp.mkfs
|
|
|
|
cat >$tmp.projects <<EOF
|
|
1:$SCRATCH_MNT
|
|
EOF
|
|
|
|
cat >$tmp.projid <<EOF
|
|
root:0
|
|
scrach:1
|
|
EOF
|
|
|
|
projid_file="$tmp.projid"
|
|
|
|
echo "*** user, group, and project"
|
|
_qmount_option "uquota,gquota,pquota"
|
|
_qmount
|
|
|
|
bsize=$(_get_file_block_size $SCRATCH_MNT)
|
|
|
|
bsoft=$(( 100 * $bsize ))
|
|
bhard=$(( 500 * $bsize ))
|
|
isoft=4
|
|
ihard=10
|
|
|
|
# non-root users need to be able to write to this filesystem
|
|
chmod 777 $SCRATCH_MNT
|
|
|
|
_exercise p
|
|
_exercise g
|
|
_exercise u
|
|
|
|
echo "*** unmount"
|
|
_scratch_unmount
|
|
|
|
|
|
_scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
|
|
cat $tmp.mkfs >>$seqres.full
|
|
# keep the blocksize and data size for dd later
|
|
. $tmp.mkfs
|
|
|
|
echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
|
|
_qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"
|
|
_qmount
|
|
_exercise uno
|
|
_exercise gno
|
|
_exercise pno
|
|
|
|
echo "*** unmount"
|
|
_scratch_unmount
|
|
|
|
# success, all done
|
|
status=0
|
|
exit
|