4 # Ensure that quota(1) displays blocksizes matching ondisk dquots.
6 # MOUNT_OPTIONS can be set to gquota to test group quota,
7 # defaults to uquota if MOUNT_OPTIONS is not set.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
11 #-----------------------------------------------------------------------
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
23 # get standard environment, filters and checks
31 umount $SCRATCH_MNT 2>/dev/null
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # real QA test starts here
38 _supported_os IRIX Linux
47 if [ -z "$MOUNT_OPTIONS" ]; then
48 export MOUNT_OPTIONS="-o uquota"
51 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
52 cat $tmp.mkfs >>$seq.full
53 chmod a+w $seq.full # arbitrary users will write here
55 # keep the blocksize from mkfs ($dbsize)
60 # setup user/group to test
61 if src/feature -U $SCRATCH_DEV ; then
62 type=u; eval `_choose_uid`
63 elif src/feature -G $SCRATCH_DEV ; then
64 type=g; eval `_choose_gid`
65 elif src/feature -P $SCRATCH_DEV ; then
66 type=p; eval `_choose_prid`
68 _notrun "No quota support at mount time"
71 # create 100 (fs-blocksize) blocks
72 _file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
75 # set limit at 1001 (1k) blocks
81 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
82 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
85 # cross check blks, softblks, hardblks <-> quota, xfs_db
86 xfs_quota -c "quota -$type -birnN $id" $SCRATCH_DEV |
87 tr -s '[:space:]' | tee -a $seq.full | perl -ne '
88 if (m[^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+)]) {
89 print "used_blocks=", $1, "\n";
90 print "soft_blocks=", $2, "\n";
91 print "hard_blocks=", $3, "\n";
93 }' | LC_COLLATE=POSIX sort >$tmp.quota
95 echo ===quota output >> $seq.full
96 cat $tmp.quota >> $seq.full
97 [ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
101 # note - does (insitu) conversion from fs blocks to 1K blocks
102 xfs_db -rc "dquot -$type $id" -c p $SCRATCH_DEV | tee -a $seq.full | perl -ne '
103 if (/^diskdq.bcount = (\d+)$/) {
104 print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
106 elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
107 print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
109 elsif (/^diskdq.blk_softlimit = (\d+)$/) {
110 print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
111 }' | LC_COLLATE=POSIX sort >$tmp.xfs_db
113 echo ===xfs_db output >> $seq.full
114 cat $tmp.xfs_db >> $seq.full
115 [ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
117 echo Comparing out of xfs_quota and xfs_db
118 diff $tmp.quota $tmp.xfs_db
119 [ $? -eq 0 ] && echo OK.