c47f4f37b545bd72b9f1b653cb8bfdd79ea8ea4e
[xfstests-dev.git] / tests / xfs / 108
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 108
6 #
7 # Simple quota accounting test for direct/buffered/mmap IO.
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 "rm -f $tmp.*; exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21 . ./common/quota
22
23 # real QA test starts here
24 _supported_fs xfs
25 _supported_os Linux
26 _require_scratch
27 _require_xfs_quota
28
29 test_files()
30 {
31         echo; echo "### create files, setting up ownership (type=$type)"
32         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
33         $XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
34         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
35         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
36         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
37                 $here/src/lstat64 $file | head -3 | _filter_scratch
38                 $XFS_IO_PROG -c lsproj $file
39         done
40 }
41
42 test_accounting()
43 {
44         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
45         echo "--- initiating parallel IO..." >>$seqres.full
46         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
47                                         $SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
48         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
49                                         $SCRATCH_MNT/direct >>$seqres.full 2>&1 &
50         $XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
51                                         $SCRATCH_MNT/mmap   >>$seqres.full 2>&1 &
52         wait
53         echo "--- completed parallel IO ($type)" >>$seqres.full
54
55         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
56                 $here/src/lstat64 $file | head -3 | _filter_scratch
57         done
58         xfs_quota -c "quota -hnb -$type $id" $QARGS | _filter_quota
59         xfs_quota -c "quota -hni -$type $id" $QARGS | _filter_quota
60         xfs_quota -c "quota -hnr -$type $id" $QARGS | _filter_quota
61 }
62
63 export MOUNT_OPTIONS="-opquota"
64 _qmount
65 _require_prjquota $SCRATCH_DEV
66
67 # real QA test starts here
68 rm -f $tmp.projects $seqres.full
69 _scratch_unmount 2>/dev/null
70 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
71 cat $tmp.mkfs >>$seqres.full
72 _scratch_mount
73
74 uid=1
75 gid=2
76 prid=3
77 export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
78 _scratch_unmount
79
80 echo; echo "### test user accounting"
81 export MOUNT_OPTIONS="-ouquota"
82 _qmount
83 type=u
84 id=$uid
85 test_files
86 test_accounting
87 _scratch_unmount 2>/dev/null
88
89 echo; echo "### test group accounting"
90 export MOUNT_OPTIONS="-ogquota"
91 _qmount
92 type=g
93 id=$gid
94 test_files
95 test_accounting
96 _scratch_unmount 2>/dev/null
97
98 #echo; echo "### test project accounting"
99 export MOUNT_OPTIONS="-opquota"
100 _qmount
101 type=p
102 id=$prid
103 test_files
104 test_accounting
105 _scratch_unmount 2>/dev/null
106
107 status=0
108 exit