2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # Ensure that quota(1) displays blocksizes matching ondisk dquots.
9 # MOUNT_OPTIONS can be set to gquota to test group quota,
10 # defaults to uquota if MOUNT_OPTIONS is not set.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
20 # get standard environment, filters and checks
28 _scratch_unmount 2>/dev/null
31 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # real QA test starts here
45 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
46 cat $tmp.mkfs >>$seqres.full
47 chmod a+w $seqres.full # arbitrary users will write here
49 # keep the blocksize from mkfs ($dbsize)
54 # setup user/group to test
55 if $here/src/feature -U $SCRATCH_DEV ; then
56 type=u; eval `_choose_uid`
57 elif $here/src/feature -G $SCRATCH_DEV ; then
58 type=g; eval `_choose_gid`
59 elif $here/src/feature -P $SCRATCH_DEV ; then
60 type=p; eval `_choose_prid`
62 _notrun "No quota support at mount time"
65 # create 100 (fs-blocksize) blocks
66 _file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
69 # set limit at 1001 (1k) blocks
75 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
76 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
79 # cross check blks, softblks, hardblks <-> quota, xfs_db
80 xfs_quota -c "quota -$type -birnN $id" $SCRATCH_DEV |
81 tr -d '\n' | tr -s '[:space:]' | tee -a $seqres.full |
82 perl -ne 'if (m[^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+)]) {
83 print "used_blocks=", $1, "\n";
84 print "soft_blocks=", $2, "\n";
85 print "hard_blocks=", $3, "\n";
87 }' | LC_COLLATE=POSIX sort >$tmp.quota
89 echo ===quota output >> $seqres.full
90 cat $tmp.quota >> $seqres.full
91 [ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
95 # note - does (insitu) conversion from fs blocks to 1K blocks
96 _scratch_xfs_db -rc "dquot -$type $id" -c p | tee -a $seqres.full | perl -ne '
97 if (/^diskdq.bcount = (\d+)$/) {
98 print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
100 elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
101 print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
103 elsif (/^diskdq.blk_softlimit = (\d+)$/) {
104 print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
105 }' | LC_COLLATE=POSIX sort >$tmp.xfs_db
107 echo ===xfs_db output >> $seqres.full
108 cat $tmp.xfs_db >> $seqres.full
109 [ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
111 echo Comparing out of xfs_quota and xfs_db
112 diff $tmp.quota $tmp.xfs_db
113 [ $? -eq 0 ] && echo OK.