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