mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
move mount stuff into common quota file, tidy a little, make a default.
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
# Exercises basic XFS quota functionality
|
# Exercises basic XFS quota functionality
|
||||||
# MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
|
# MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
|
||||||
# options are: (-o) usrquota, grpquota, uqnoenforce, gqnoenforce
|
# options are: (-o) usrquota, grpquota, uqnoenforce, gqnoenforce
|
||||||
|
# default is: usrquota
|
||||||
#
|
#
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
# Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||||
@@ -50,28 +51,25 @@ status=1 # failure is the default!
|
|||||||
|
|
||||||
# get standard environment, filters and checks
|
# get standard environment, filters and checks
|
||||||
. ./common.rc
|
. ./common.rc
|
||||||
. ./common.quota
|
|
||||||
. ./common.filter
|
. ./common.filter
|
||||||
|
. ./common.quota
|
||||||
|
|
||||||
_cleanup()
|
_cleanup()
|
||||||
{
|
{
|
||||||
echo; echo "*** unmount"
|
echo; echo "*** unmount"
|
||||||
umount $SCRATCH_MNT 2>/dev/null
|
umount $SCRATCH_MNT 2>/dev/null
|
||||||
rm -f $tmp.*
|
rm -f $tmp.*
|
||||||
}
|
}
|
||||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||||
rm -f $seq.full $seq.out
|
rm -f $seq.full $seq.out
|
||||||
|
|
||||||
_require_quota
|
|
||||||
_require_scratch
|
_require_scratch
|
||||||
|
_require_quota
|
||||||
|
|
||||||
_mymount()
|
# setup a default run
|
||||||
{
|
if [ -z "$MOUNT_OPTIONS" ]; then
|
||||||
umount $SCRATCH_DEV >/dev/null 2>&1
|
MOUNT_OPTIONS="-o usrquota"; export MOUNT_OPTIONS
|
||||||
mount -t xfs $SCRATCH_DEV $SCRATCH_MNT || _fail "mount failed"
|
fi
|
||||||
chmod ugo+rwx $SCRATCH_MNT
|
|
||||||
misc/quot $SCRATCH_DEV >>$seq.full 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# real QA test starts here
|
# real QA test starts here
|
||||||
mkfs -t xfs -f $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
|
mkfs -t xfs -f $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
|
||||||
@@ -81,7 +79,7 @@ chmod a+w $seq.full # arbitrary users will write here
|
|||||||
# keep the blocksize and data size for dd later
|
# keep the blocksize and data size for dd later
|
||||||
. $tmp.mkfs
|
. $tmp.mkfs
|
||||||
|
|
||||||
_mymount
|
_qmount
|
||||||
|
|
||||||
# setup exactly what it is we'll be testing
|
# setup exactly what it is we'll be testing
|
||||||
if src/feature -u $SCRATCH_DEV
|
if src/feature -u $SCRATCH_DEV
|
||||||
@@ -117,13 +115,13 @@ echo
|
|||||||
echo "*** push past the soft inode limit" | tee -a $seq.full
|
echo "*** push past the soft inode limit" | tee -a $seq.full
|
||||||
_file_as_id $SCRATCH_MNT/softie1 $id $type $dbsize 0
|
_file_as_id $SCRATCH_MNT/softie1 $id $type $dbsize 0
|
||||||
_file_as_id $SCRATCH_MNT/softie2 $id $type $dbsize 0
|
_file_as_id $SCRATCH_MNT/softie2 $id $type $dbsize 0
|
||||||
_mymount
|
_qmount
|
||||||
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "*** push past the soft block limit" | tee -a $seq.full
|
echo "*** push past the soft block limit" | tee -a $seq.full
|
||||||
_file_as_id $SCRATCH_MNT/softie $id $type $dbsize 140
|
_file_as_id $SCRATCH_MNT/softie $id $type $dbsize 140
|
||||||
_mymount
|
_qmount
|
||||||
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@@ -132,13 +130,13 @@ for i in 1 2 3 4 5 6 7 8 9 10 11 12
|
|||||||
do
|
do
|
||||||
_file_as_id $SCRATCH_MNT/hard$i $id $type $dbsize 0
|
_file_as_id $SCRATCH_MNT/hard$i $id $type $dbsize 0
|
||||||
done
|
done
|
||||||
_mymount
|
_qmount
|
||||||
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
|
echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
|
||||||
_file_as_id $SCRATCH_MNT/softie $id $type $dbsize 540
|
_file_as_id $SCRATCH_MNT/softie $id $type $dbsize 540
|
||||||
_mymount
|
_qmount
|
||||||
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
repquota -m -$type $SCRATCH_DEV | _filter_repquota
|
||||||
|
|
||||||
# success, all done
|
# success, all done
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# XFS QA Test No. 052
|
||||||
|
# $Id: 1.1 $
|
||||||
|
#
|
||||||
|
# Ensure that quota(1) displays blocksizes matching ondisk dquots.
|
||||||
|
#
|
||||||
|
# MOUNT_OPTIONS can be set to grpquota to test group quota,
|
||||||
|
# defaults to usrquota if MOUNT_OPTIONS is not set.
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2000 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!
|
||||||
|
|
||||||
|
# get standard environment, filters and checks
|
||||||
|
. ./common.rc
|
||||||
|
. ./common.filter
|
||||||
|
. ./common.quota
|
||||||
|
|
||||||
|
_cleanup()
|
||||||
|
{
|
||||||
|
umount $SCRATCH_MNT 2>/dev/null
|
||||||
|
rm -f $tmp.*
|
||||||
|
}
|
||||||
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||||
|
rm -f $seq.full $seq.out
|
||||||
|
|
||||||
|
_require_scratch
|
||||||
|
_require_quota
|
||||||
|
|
||||||
|
# setup a default run
|
||||||
|
if [ -z "$MOUNT_OPTIONS" ]; then
|
||||||
|
MOUNT_OPTIONS="-o usrquota"; export MOUNT_OPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
|
# real QA test starts here
|
||||||
|
mkfs -t xfs -f $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
|
||||||
|
cat $tmp.mkfs >>$seq.full
|
||||||
|
chmod a+w $seq.full # arbitrary users will write here
|
||||||
|
|
||||||
|
# keep the blocksize from mkfs ($dbsize)
|
||||||
|
. $tmp.mkfs
|
||||||
|
|
||||||
|
_qmount
|
||||||
|
|
||||||
|
# setup user/group to test
|
||||||
|
if src/feature -U $SCRATCH_DEV ; then
|
||||||
|
type=u ; id=`_choose_uid`
|
||||||
|
elif src/feature -G $SCRATCH_DEV ; then
|
||||||
|
type=g ; id=`_choose_gid`
|
||||||
|
else
|
||||||
|
_notrun "No quota support at mount time"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create 100 (fs-blocksize) blocks
|
||||||
|
_file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
|
||||||
|
sync
|
||||||
|
|
||||||
|
# set limit at 1001 (1k) blocks
|
||||||
|
setquota -n -$type $id $SCRATCH_DEV 1001 1001 10 10
|
||||||
|
|
||||||
|
# cross check blks, softblks, hardblks <-> quota, xfs_db
|
||||||
|
quota $type -n $id | tee -a $seq.full | perl -ne '
|
||||||
|
if (m,^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+),) {
|
||||||
|
print "used_blocks=", $1, "\n";
|
||||||
|
print "soft_blocks=", $2, "\n";
|
||||||
|
print "hard_blocks=", $3, "\n";
|
||||||
|
}' | LC_COLLATE=POSIX sort >$tmp.quota
|
||||||
|
|
||||||
|
echo ===quota output >> $seq.full
|
||||||
|
cat $tmp.quota >> $seq.full
|
||||||
|
[ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
|
||||||
|
|
||||||
|
umount $SCRATCH_MNT
|
||||||
|
|
||||||
|
# note - does (insitu) conversion from fs blocks to 1K blocks
|
||||||
|
xfs_db -rc "dquot -$type $id" -c p $SCRATCH_DEV | tee -a $seq.full | perl -ne '
|
||||||
|
if (/^diskdq.bcount = (\d+)$/) {
|
||||||
|
print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
|
||||||
|
}
|
||||||
|
elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
|
||||||
|
print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
|
||||||
|
}
|
||||||
|
elsif (/^diskdq.blk_softlimit = (\d+)$/) {
|
||||||
|
print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
|
||||||
|
}' | LC_COLLATE=POSIX sort >$tmp.xfs_db
|
||||||
|
|
||||||
|
echo ===xfs_db output >> $seq.full
|
||||||
|
cat $tmp.xfs_db >> $seq.full
|
||||||
|
[ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
|
||||||
|
|
||||||
|
echo Comparing out of quota and xfs_db
|
||||||
|
diff $tmp.quota $tmp.xfs_db
|
||||||
|
[ $? -eq 0 ] && echo OK.
|
||||||
|
|
||||||
|
# success, all done
|
||||||
|
status=0
|
||||||
|
exit
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
QA output created by 052
|
||||||
|
meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks
|
||||||
|
data = bsize=XXX blocks=XXX, imaxpct=PCT
|
||||||
|
= sunit=XXX swidth=XXX, unwritten=X
|
||||||
|
naming =VERN bsize=XXX
|
||||||
|
log =LDEV bsize=XXX blocks=XXX
|
||||||
|
realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX
|
||||||
|
Comparing out of quota and xfs_db
|
||||||
|
OK.
|
||||||
@@ -87,6 +87,13 @@ _filter_repquota()
|
|||||||
perl -ne 's/^(\w+)\s+([-|+])/[NAME] \2/g; print'
|
perl -ne 's/^(\w+)\s+([-|+])/[NAME] \2/g; print'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_qmount()
|
||||||
|
{
|
||||||
|
umount $SCRATCH_DEV >/dev/null 2>&1
|
||||||
|
mount -t xfs $SCRATCH_DEV $SCRATCH_MNT || _fail "qmount failed"
|
||||||
|
chmod ugo+rwx $SCRATCH_MNT
|
||||||
|
misc/quot $SCRATCH_DEV >>$seq.full 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# make sure this script returns success
|
# make sure this script returns success
|
||||||
/bin/true
|
/bin/true
|
||||||
|
|||||||
@@ -100,3 +100,4 @@ auto dxm@sgi.com
|
|||||||
049 rw auto
|
049 rw auto
|
||||||
050 quota auto
|
050 quota auto
|
||||||
051 acl auto
|
051 acl auto
|
||||||
|
052 quota db
|
||||||
|
|||||||
+4
-2
@@ -33,8 +33,10 @@
|
|||||||
/*
|
/*
|
||||||
* Test for filesystem features on given mount point or device
|
* Test for filesystem features on given mount point or device
|
||||||
* -q test for quota support (kernel compile option)
|
* -q test for quota support (kernel compile option)
|
||||||
* -u test for user quota support (mount option)
|
* -u test for user quota enforcement support (mount option)
|
||||||
* -g test for group quota support (mount option)
|
* -g test for group quota enforcement support (mount option)
|
||||||
|
* -U test for user quota accounting support (mount option)
|
||||||
|
* -G test for group quota accounting support (mount option)
|
||||||
* Return code: 0 is true, anything else is error/not supported
|
* Return code: 0 is true, anything else is error/not supported
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user