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
33 echo; echo "### create files, setting up ownership (type=$type)"
34 rm -f $SCRATCH_MNT/{buffer,direct,mmap}
35 touch $SCRATCH_MNT/{buffer,direct,mmap}
36 chown $qa_user $SCRATCH_MNT/{buffer,direct,mmap}
37 chgrp $qa_group $SCRATCH_MNT/{buffer,direct,mmap}
38 for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
39 $here/src/lstat64 $file | head -2 | _filter_scratch
47 read id exceed blocks bsoft bhard inodes isoft ihard
48 if [ "$blocks" -lt "$wroteblocks" ]; then
49 echo "Too few blocks used (type=$type)"
50 # Save 5% for overhead of metadata or different block size
51 elif [ "$blocks" -gt $((wroteblocks+wroteblocks/20)) ]; then
52 echo "Too many blocks used (type=$type)"
53 elif [ "$inodes" != "$wrotefiles" ]; then
54 echo "Bad number of inodes used (type=$type)"
56 echo "Usage OK (type=$type)"
62 echo "### some controlled buffered, direct and mmapd IO (type=$type)"
63 echo "--- initiating parallel IO..." >>$seqres.full
64 # Small ios here because ext3 will account for indirect blocks too ...
65 # 48k will fit w/o indirect for 4k blocks (default blocksize)
66 $XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
67 $SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
68 $XFS_IO_PROG -c 'pwrite 0 48k' -d \
69 $SCRATCH_MNT/direct >>$seqres.full 2>&1 &
70 $XFS_IO_PROG -c 't 48k' -c 'mm -rw 0 48k' -c 'mw 0 48k' -c 'ms -s' \
71 $SCRATCH_MNT/mmap >>$seqres.full 2>&1 &
73 echo "--- completed parallel IO ($type)" >>$seqres.full
75 for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
76 $here/src/lstat64 $file | head -2 | _filter_scratch
79 if [ $type == 'u' ]; then
84 repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
87 # real QA test starts here
90 _scratch_unmount 2>/dev/null
91 _scratch_mkfs >> $seqres.full 2>&1
92 _scratch_mount "-o usrquota,grpquota"
93 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
94 quotaon $SCRATCH_MNT 2>/dev/null
97 echo; echo "### test user accounting"
98 export MOUNT_OPTIONS="-o usrquota"
100 quotaon $SCRATCH_MNT 2>/dev/null
104 _scratch_unmount 2>/dev/null
106 echo; echo "### test group accounting"
107 export MOUNT_OPTIONS="-o grpquota"
109 quotaon $SCRATCH_MNT 2>/dev/null
113 _scratch_unmount 2>/dev/null