2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Eric Sandeen. All Rights Reserved.
4 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
8 # Simple quota accounting test for direct/buffered/mmap IO.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
19 # get standard environment, filters and checks
24 # real QA test starts here
34 echo; echo "### create files, setting up ownership (type=$type)"
35 rm -f $SCRATCH_MNT/{buffer,direct,mmap}
36 touch $SCRATCH_MNT/{buffer,direct,mmap}
37 chown $qa_user $SCRATCH_MNT/{buffer,direct,mmap}
38 chgrp $qa_group $SCRATCH_MNT/{buffer,direct,mmap}
39 for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
40 $here/src/lstat64 $file | head -2 | _filter_scratch
48 read id exceed blocks bsoft bhard inodes isoft ihard
49 if [ "$blocks" -lt "$wroteblocks" ]; then
50 echo "Too few blocks used (type=$type)"
51 # Save 5% for overhead of metadata or different block size
52 elif [ "$blocks" -gt $((wroteblocks+wroteblocks/20)) ]; then
53 echo "Too many blocks used (type=$type)"
54 elif [ "$inodes" != "$wrotefiles" ]; then
55 echo "Bad number of inodes used (type=$type)"
57 echo "Usage OK (type=$type)"
63 echo "### some controlled buffered, direct and mmapd IO (type=$type)"
64 echo "--- initiating parallel IO..." >>$seqres.full
65 # Small ios here because ext3 will account for indirect blocks too ...
66 # 48k will fit w/o indirect for 4k blocks (default blocksize)
67 $XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
68 $SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
69 $XFS_IO_PROG -c 'pwrite 0 48k' -d \
70 $SCRATCH_MNT/direct >>$seqres.full 2>&1 &
71 $XFS_IO_PROG -c 't 48k' -c 'mm -rw 0 48k' -c 'mw 0 48k' -c 'ms -s' \
72 $SCRATCH_MNT/mmap >>$seqres.full 2>&1 &
74 echo "--- completed parallel IO ($type)" >>$seqres.full
76 for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
77 $here/src/lstat64 $file | head -2 | _filter_scratch
80 if [ $type == 'u' ]; then
85 repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
88 # real QA test starts here
91 _scratch_unmount 2>/dev/null
92 _scratch_mkfs >> $seqres.full 2>&1
93 _scratch_mount "-o usrquota,grpquota"
94 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
95 quotaon $SCRATCH_MNT 2>/dev/null
98 echo; echo "### test user accounting"
99 export MOUNT_OPTIONS="-o usrquota"
101 quotaon $SCRATCH_MNT 2>/dev/null
105 _scratch_unmount 2>/dev/null
107 echo; echo "### test group accounting"
108 export MOUNT_OPTIONS="-o grpquota"
110 quotaon $SCRATCH_MNT 2>/dev/null
114 _scratch_unmount 2>/dev/null