0af22443ae5ea891532885f1278a869a41fbafd4
[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 . ./common/preamble
10 _begin_fstest quota auto quick
11
12 # Import common functions.
13 . ./common/filter
14 . ./common/quota
15
16 # real QA test starts here
17 _supported_fs xfs
18 _require_scratch
19 _require_xfs_quota
20
21 test_files()
22 {
23         echo; echo "### create files, setting up ownership (type=$type)"
24         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
25         $XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
26         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
27         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
28         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
29                 $here/src/lstat64 $file | head -3 | _filter_scratch
30                 $XFS_IO_PROG -c lsproj $file
31         done
32 }
33
34 test_accounting()
35 {
36         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
37         echo "--- initiating parallel IO..." >>$seqres.full
38         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
39                                         $SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
40         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
41                                         $SCRATCH_MNT/direct >>$seqres.full 2>&1 &
42         $XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
43                                         $SCRATCH_MNT/mmap   >>$seqres.full 2>&1 &
44         wait
45         echo "--- completed parallel IO ($type)" >>$seqres.full
46
47         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
48                 $here/src/lstat64 $file | head -3 | _filter_scratch
49         done
50         xfs_quota -c "quota -hnb -$type $id" $QARGS | _filter_quota
51         xfs_quota -c "quota -hni -$type $id" $QARGS | _filter_quota
52         xfs_quota -c "quota -hnr -$type $id" $QARGS | _filter_quota
53 }
54
55 export MOUNT_OPTIONS="-opquota"
56 _scratch_mkfs_xfs >> $seqres.full
57 _qmount
58 _require_prjquota $SCRATCH_DEV
59
60 # real QA test starts here
61 rm -f $tmp.projects $seqres.full
62 _scratch_unmount 2>/dev/null
63 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
64 cat $tmp.mkfs >>$seqres.full
65 _scratch_mount
66
67 uid=1
68 gid=2
69 prid=3
70 export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
71 _scratch_unmount
72
73 echo; echo "### test user accounting"
74 export MOUNT_OPTIONS="-ouquota"
75 _qmount
76 type=u
77 id=$uid
78 test_files
79 test_accounting
80 _scratch_unmount 2>/dev/null
81
82 echo; echo "### test group accounting"
83 export MOUNT_OPTIONS="-ogquota"
84 _qmount
85 type=g
86 id=$gid
87 test_files
88 test_accounting
89 _scratch_unmount 2>/dev/null
90
91 #echo; echo "### test project accounting"
92 export MOUNT_OPTIONS="-opquota"
93 _qmount
94 type=p
95 id=$prid
96 test_files
97 test_accounting
98 _scratch_unmount 2>/dev/null
99
100 status=0
101 exit