xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / xfs / 263
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 263
6 #
7 # test xfs_quota state command
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/quota
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs xfs
36
37 _require_scratch
38 _require_xfs_quota
39
40 # We could test older, non-project capable kernels but keep it simpler;
41 # Only test crc and beyond (but we will test with and without the feature)
42 _require_xfs_mkfs_crc
43 _require_xfs_crc
44
45 rm -f $seqres.full
46
47 function option_string()
48 {
49         VAL=$1
50         # Treat 3 options as a bit field, prjquota|grpquota|usrquota
51         OPT="rw"
52         if [ "$((VAL & 4))" -ne "0" ]; then OPT=prjquota,${OPT}; fi;
53         if [ "$((VAL & 2))" -ne "0" ]; then OPT=grpquota,${OPT}; fi;
54         if [ "$((VAL & 1))" -ne "0" ]; then OPT=usrquota,${OPT}; fi;
55         echo $OPT
56 }
57
58 filter_quota_state() {
59         sed -e 's/Inode: #[0-9]\+/Inode #XXX/g' \
60             -e '/max warnings:/d' \
61             -e '/Blocks grace time:/d' \
62             -e '/Inodes grace time:/d' \
63                 | _filter_scratch
64 }
65
66 filter_quota_state2() {
67         sed -e '/User quota state on/d' \
68             -e '/ Accounting: /d' \
69             -e '/ Enforcement: /d' \
70             -e '/ Inode: /d' \
71             -e '/Blocks max warnings: /d' \
72             -e '/Inodes max warnings: /d' \
73                 | _filter_scratch
74 }
75
76 function test_all_state()
77 {
78         for I in `seq 0 7`; do
79                 OPTIONS=`option_string $I`
80                 echo "== Options: $OPTIONS =="
81                 # Some combinations won't mount on V4 supers (grp + prj)
82                 _qmount_option "$OPTIONS"
83                 _try_scratch_mount &>> $seqres.full || continue
84                 $XFS_QUOTA_PROG -x -c "state -u" $SCRATCH_MNT | filter_quota_state
85                 $XFS_QUOTA_PROG -x -c "state -g" $SCRATCH_MNT | filter_quota_state
86                 $XFS_QUOTA_PROG -x -c "state -p" $SCRATCH_MNT | filter_quota_state
87                 $XFS_QUOTA_PROG -x -c "state -u" $SCRATCH_MNT | filter_quota_state2
88                 _scratch_unmount
89         done
90 }
91
92 echo "==== NO CRC ===="
93 # Control size to control inode numbers
94 _scratch_mkfs_xfs "-m crc=0 -n ftype=0 -d size=512m" >> $seqres.full
95 test_all_state
96
97 echo "==== CRC ===="
98 _scratch_mkfs_xfs "-m crc=1 -d size=512m" >>$seqres.full
99 test_all_state
100
101 status=0
102 exit