xfstests: support post-udev device mapper nodes
[xfstests-dev.git] / 108
1 #! /bin/bash
2 # FS QA Test No. 108
3 #
4 # Simple quota accounting test for direct/buffered/mmap IO.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 # creator
25 owner=nathans@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 . ./common.quota
39
40 # real QA test starts here
41 _supported_fs xfs
42 _supported_os Linux #IRIX
43 _require_scratch
44 _require_xfs_quota
45
46 test_files()
47 {
48         echo; echo "### create files, setting up ownership (type=$type)"
49         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
50         $XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
51         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
52         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
53         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
54                 $here/src/lstat64 $file | head -3 | _filter_scratch
55                 $XFS_IO_PROG -c lsproj $file
56         done
57 }
58
59 test_accounting()
60 {
61         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
62         echo "--- initiating parallel IO..." >>$seq.full
63         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
64                                         $SCRATCH_MNT/buffer >>$seq.full 2>&1 &
65         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
66                                         $SCRATCH_MNT/direct >>$seq.full 2>&1 &
67         $XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
68                                         $SCRATCH_MNT/mmap   >>$seq.full 2>&1 &
69         wait
70         echo "--- completed parallel IO ($type)" >>$seq.full
71
72         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
73                 $here/src/lstat64 $file | head -3 | _filter_scratch
74         done
75         xfs_quota -c "quota -hnb -$type $id" $QARGS | _filter_scratch | _filter_spaces
76         xfs_quota -c "quota -hni -$type $id" $QARGS | _filter_scratch | _filter_spaces
77         xfs_quota -c "quota -hnr -$type $id" $QARGS | _filter_scratch | _filter_spaces
78 }
79
80 export MOUNT_OPTIONS="-opquota"
81 _qmount
82 _require_prjquota $SCRATCH_DEV
83
84 # real QA test starts here
85 rm -f $tmp.projects $seq.full
86 umount $SCRATCH_DEV 2>/dev/null
87 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
88 cat $tmp.mkfs >>$seq.full
89 _scratch_mount
90
91 uid=1
92 gid=2
93 prid=3
94 export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
95 umount $SCRATCH_DEV
96
97 echo; echo "### test user accounting"
98 export MOUNT_OPTIONS="-ouquota"
99 _qmount
100 type=u
101 id=$uid
102 test_files
103 test_accounting
104 umount $SCRATCH_DEV 2>/dev/null
105
106 echo; echo "### test group accounting"
107 export MOUNT_OPTIONS="-ogquota"
108 _qmount
109 type=g
110 id=$gid
111 test_files
112 test_accounting
113 umount $SCRATCH_DEV 2>/dev/null
114
115 #echo; echo "### test project accounting"
116 export MOUNT_OPTIONS="-opquota"
117 _qmount
118 type=p
119 id=$prid
120 test_files
121 test_accounting
122 umount $SCRATCH_DEV 2>/dev/null
123
124 status=0
125 exit