mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
e52c143e3c
Merge of master-melb:xfs-cmds:22775a by kenmcd.
218 lines
6.0 KiB
Bash
Executable File
218 lines
6.0 KiB
Bash
Executable File
#! /bin/sh
|
|
# FS QA Test No. 106
|
|
#
|
|
# Exercise basic xfs_quota functionality (user/group/project quota)
|
|
#
|
|
#-----------------------------------------------------------------------
|
|
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
|
|
#
|
|
# 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!
|
|
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common.rc
|
|
. ./common.filter
|
|
. ./common.quota
|
|
|
|
_supported_fs xfs
|
|
_supported_os Linux #IRIX
|
|
_require_scratch
|
|
_require_quota
|
|
|
|
# real QA test starts here
|
|
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
|
cat $tmp.mkfs >>$seq.full
|
|
. $tmp.mkfs
|
|
|
|
# setup a default run
|
|
[ -z "$MOUNT_OPTIONS" ] && export MOUNT_OPTIONS="-o uquota"
|
|
|
|
# initial populate
|
|
_qmount
|
|
target=$SCRATCH_MNT/target
|
|
ltp/fsstress -s 0xdeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
|
|
ltp/fsstress -s 0xdeed -m8 -z -p4 -n1000 -fchproj=500 -fchown=500 -d $target
|
|
|
|
# also use space, to be able to go over/under limits easily
|
|
uid=255
|
|
gid=254
|
|
prid=253
|
|
rm -f $SCRATCH_MNT/resv
|
|
xfs_io -fc "resvsp 0 200m" -c "chproj $prid" $SCRATCH_MNT/resv
|
|
chown $uid $SCRATCH_MNT/resv
|
|
chgrp $gid $SCRATCH_MNT/resv
|
|
|
|
_qmount
|
|
|
|
filter_xfs_quota()
|
|
{
|
|
perl -ne "
|
|
s,$SCRATCH_MNT,[SCR_MNT],;
|
|
s,$SCRATCH_DEV,[SCR_DEV],;
|
|
s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
|
|
s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
|
|
print;"
|
|
}
|
|
|
|
test_quot()
|
|
{
|
|
echo "checking quot command (type=$type)" # not deterministic on blks
|
|
xfs_quota -x -c "quot -n -$type" $SCRATCH_MNT >>$seq.full 2>&1
|
|
}
|
|
|
|
test_report()
|
|
{
|
|
echo "checking report command (type=$type)"
|
|
xfs_quota -x -c "report -h -$type -U 256" $SCRATCH_MNT
|
|
}
|
|
|
|
test_limit1()
|
|
{
|
|
echo "checking limit command, pass 1 (type=$type)"
|
|
xfs_quota -x -c "limit -$type bsoft=100m bhard=100m ihard=2 $id" \
|
|
$SCRATCH_MNT
|
|
xfs_quota -x -c "limit -$type isoft=1 rtbsoft=100m rtbhard=110m $id"\
|
|
$SCRATCH_MNT
|
|
sleep 2 # let the timer day transition happen
|
|
xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
|
|
#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
|
|
}
|
|
|
|
test_limit2()
|
|
{
|
|
# push limits up high, so that timers are cleared, etc. (for later)
|
|
echo "checking limit command, pass2 (type=$type)"
|
|
xfs_quota -x -c "limit -$type bsoft=300m bhard=400m ihard=8800 $id" \
|
|
$SCRATCH_MNT
|
|
xfs_quota -x -c "limit -$type isoft=8000 rtbsoft=310m rtbhard=410m $id"\
|
|
$SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
|
|
#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
|
|
}
|
|
|
|
test_warn()
|
|
{
|
|
echo "checking warn command (type=$type)"
|
|
xfs_quota -x -c "warn -$type -b 4 $id" $SCRATCH_MNT
|
|
xfs_quota -x -c "warn -$type -i 3 $id" $SCRATCH_MNT
|
|
#xfs_quota -x -c "warn -$type -r 2 $id" $SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
|
|
#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
|
|
}
|
|
|
|
test_timer()
|
|
{
|
|
echo "checking timer command (type=$type)"
|
|
xfs_quota -x -c "timer -$type -b 3days" $SCRATCH_MNT
|
|
xfs_quota -x -c "timer -$type -i 2days" $SCRATCH_MNT
|
|
#xfs_quota -x -c "timer -$type -r 1day" $SCRATCH_MNT
|
|
}
|
|
|
|
test_state()
|
|
{
|
|
echo "checking state command (type=$type)"
|
|
xfs_quota -x -c "state -$type" $SCRATCH_MNT
|
|
# not yet working properly?
|
|
#echo "checking disable command (type=$type)"
|
|
#xfs_quota -x -c "disable -$type -v" $SCRATCH_MNT
|
|
#echo "checking enable command (type=$type)"
|
|
#xfs_quota -x -c "enable -$type -v" $SCRATCH_MNT
|
|
#echo "checking off command (type=$type)"
|
|
#xfs_quota -x -c "off -$type -v" $SCRATCH_MNT
|
|
#echo "checking remove command (type=$type)"
|
|
#xfs_quota -x -c "remove -$type -v" $SCRATCH_MNT
|
|
}
|
|
|
|
test_backup()
|
|
{
|
|
echo "checking dump command (type=$type)"
|
|
rm -f $tmp.backup
|
|
xfs_quota -x -c "dump -$type -f $tmp.backup -U 256" $SCRATCH_MNT
|
|
cat $tmp.backup
|
|
|
|
echo "changing limits (type=$type)"
|
|
xfs_quota -x -c "limit -$type isoft=1000 ihard=1100 $id" $SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
|
|
|
|
echo "checking restore command (type=$type)"
|
|
xfs_quota -x -c "restore -$type -f $tmp.backup" $SCRATCH_MNT
|
|
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
|
|
rm -f $tmp.backup
|
|
}
|
|
|
|
test_xfs_quota()
|
|
{
|
|
test_quot ; echo
|
|
test_report ; echo
|
|
test_timer ; echo
|
|
test_limit1 ; echo
|
|
test_warn ; echo
|
|
test_limit2 ; echo
|
|
test_backup ; echo
|
|
test_state ; echo
|
|
echo ; echo
|
|
}
|
|
|
|
# real QA test starts here
|
|
export MOUNT_OPTIONS="-ouquota"
|
|
_qmount
|
|
type=u
|
|
id=$uid
|
|
test_xfs_quota | filter_xfs_quota
|
|
|
|
export MOUNT_OPTIONS="-ogquota"
|
|
_qmount
|
|
type=g
|
|
id=$gid
|
|
test_xfs_quota | filter_xfs_quota
|
|
|
|
export MOUNT_OPTIONS="-opquota"
|
|
_qmount
|
|
type=p
|
|
id=$prid
|
|
test_xfs_quota | filter_xfs_quota
|
|
|
|
umount $SCRATCH_DEV
|
|
status=0
|
|
exit
|