2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 052
|
|
|
|
|
#
|
|
|
|
|
# Ensure that quota(1) displays blocksizes matching ondisk dquots.
|
|
|
|
|
#
|
|
|
|
|
# MOUNT_OPTIONS can be set to gquota to test group quota,
|
|
|
|
|
# defaults to uquota if MOUNT_OPTIONS is not set.
|
2009-05-12 13:24:15 -05:00
|
|
|
#
|
2001-03-20 07:17:52 +00:00
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2001-03-20 07:17:52 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/quota
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2004-06-15 07:32:36 +00:00
|
|
|
cd /
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2001-03-20 07:17:52 +00:00
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
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
|
2017-07-20 21:22:05 -07:00
|
|
|
_supported_os Linux
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $seqres.full
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
_require_scratch
|
2009-08-10 13:18:50 -05:00
|
|
|
_require_xfs_quota
|
2005-07-08 15:05:17 +00:00
|
|
|
_require_nobody
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
# setup a default run
|
2007-04-20 03:58:19 +00:00
|
|
|
_qmount_option uquota
|
2001-03-20 07:17:52 +00:00
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
2013-03-15 12:28:02 +00:00
|
|
|
cat $tmp.mkfs >>$seqres.full
|
|
|
|
|
chmod a+w $seqres.full # arbitrary users will write here
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
# keep the blocksize from mkfs ($dbsize)
|
|
|
|
|
. $tmp.mkfs
|
|
|
|
|
|
|
|
|
|
_qmount
|
|
|
|
|
|
|
|
|
|
# setup user/group to test
|
|
|
|
|
if src/feature -U $SCRATCH_DEV ; then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=u; eval `_choose_uid`
|
2001-03-20 07:17:52 +00:00
|
|
|
elif src/feature -G $SCRATCH_DEV ; then
|
2004-07-30 05:28:14 +00:00
|
|
|
type=g; eval `_choose_gid`
|
2005-12-14 05:04:52 +00:00
|
|
|
elif src/feature -P $SCRATCH_DEV ; then
|
|
|
|
|
type=p; eval `_choose_prid`
|
2001-03-20 07:17:52 +00:00
|
|
|
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
|
|
|
|
|
|
2004-07-30 05:28:14 +00:00
|
|
|
# set limit at 1001 (1k) blocks
|
|
|
|
|
bsoft=1001
|
|
|
|
|
bhard=1001
|
|
|
|
|
isoft=10
|
|
|
|
|
ihard=10
|
2005-12-14 05:04:52 +00:00
|
|
|
xfs_quota -x \
|
|
|
|
|
-c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
|
|
|
|
|
-c "limit -$type isoft=$isoft ihard=$ihard $id" \
|
|
|
|
|
$SCRATCH_DEV
|
2004-07-30 05:28:14 +00:00
|
|
|
|
2005-12-14 05:04:52 +00:00
|
|
|
# cross check blks, softblks, hardblks <-> quota, xfs_db
|
|
|
|
|
xfs_quota -c "quota -$type -birnN $id" $SCRATCH_DEV |
|
2013-03-15 12:28:02 +00:00
|
|
|
tr -d '\n' | tr -s '[:space:]' | tee -a $seqres.full |
|
2008-11-06 15:10:24 +00:00
|
|
|
perl -ne 'if (m[^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+)]) {
|
2001-03-20 07:17:52 +00:00
|
|
|
print "used_blocks=", $1, "\n";
|
|
|
|
|
print "soft_blocks=", $2, "\n";
|
|
|
|
|
print "hard_blocks=", $3, "\n";
|
2001-04-11 06:10:08 +00:00
|
|
|
$next = 0;
|
2005-12-14 05:04:52 +00:00
|
|
|
}' | LC_COLLATE=POSIX sort >$tmp.quota
|
2001-03-20 07:17:52 +00:00
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
echo ===quota output >> $seqres.full
|
|
|
|
|
cat $tmp.quota >> $seqres.full
|
2001-03-20 07:17:52 +00:00
|
|
|
[ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
|
|
|
|
|
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount
|
2001-03-20 07:17:52 +00:00
|
|
|
|
|
|
|
|
# note - does (insitu) conversion from fs blocks to 1K blocks
|
2016-10-17 15:09:34 -07:00
|
|
|
_scratch_xfs_db -rc "dquot -$type $id" -c p | tee -a $seqres.full | perl -ne '
|
2001-03-20 07:17:52 +00:00
|
|
|
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
|
|
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
echo ===xfs_db output >> $seqres.full
|
|
|
|
|
cat $tmp.xfs_db >> $seqres.full
|
2001-03-20 07:17:52 +00:00
|
|
|
[ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
|
|
|
|
|
|
2005-12-14 05:04:52 +00:00
|
|
|
echo Comparing out of xfs_quota and xfs_db
|
|
|
|
|
diff $tmp.quota $tmp.xfs_db
|
2001-03-20 07:17:52 +00:00
|
|
|
[ $? -eq 0 ] && echo OK.
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|