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 _begin_fstest auto quota quick
13 # Import common functions.
17 # real QA test starts here
26 echo; echo "### create files, setting up ownership (type=$type)"
27 rm -f $SCRATCH_MNT/{buffer,direct,mmap}
28 touch $SCRATCH_MNT/{buffer,direct,mmap}
29 chown $qa_user $SCRATCH_MNT/{buffer,direct,mmap}
30 chgrp $qa_group $SCRATCH_MNT/{buffer,direct,mmap}
31 for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
32 $here/src/lstat64 $file | head -2 | _filter_scratch
40 read id exceed blocks bsoft bhard inodes isoft ihard
41 if [ "$blocks" -lt "$wroteblocks" ]; then
42 echo "Too few blocks used (type=$type)"
43 # Save 5% for overhead of metadata or different block size
44 elif [ "$blocks" -gt $((wroteblocks+wroteblocks/20)) ]; then
45 echo "Too many blocks used (type=$type)"
46 elif [ "$inodes" != "$wrotefiles" ]; then
47 echo "Bad number of inodes used (type=$type)"
49 echo "Usage OK (type=$type)"
55 echo "### some controlled buffered, direct and mmapd IO (type=$type)"
56 echo "--- initiating parallel IO..." >>$seqres.full
57 # Small ios here because ext3 will account for indirect blocks too ...
58 # 48k will fit w/o indirect for 4k blocks (default blocksize)
59 $XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
60 $SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
61 $XFS_IO_PROG -c 'pwrite 0 48k' -d \
62 $SCRATCH_MNT/direct >>$seqres.full 2>&1 &
63 $XFS_IO_PROG -c 't 48k' -c 'mm -rw 0 48k' -c 'mw 0 48k' -c 'ms -s' \
64 $SCRATCH_MNT/mmap >>$seqres.full 2>&1 &
66 echo "--- completed parallel IO ($type)" >>$seqres.full
68 for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
69 $here/src/lstat64 $file | head -2 | _filter_scratch
72 if [ $type == 'u' ]; then
77 repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
80 # real QA test starts here
82 _scratch_unmount 2>/dev/null
83 _scratch_mkfs >> $seqres.full 2>&1
84 _scratch_mount "-o usrquota,grpquota"
85 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
86 quotaon $SCRATCH_MNT 2>/dev/null
89 echo; echo "### test user accounting"
90 export MOUNT_OPTIONS="-o usrquota"
92 quotaon $SCRATCH_MNT 2>/dev/null
96 _scratch_unmount 2>/dev/null
98 echo; echo "### test group accounting"
99 export MOUNT_OPTIONS="-o grpquota"
101 quotaon $SCRATCH_MNT 2>/dev/null
105 _scratch_unmount 2>/dev/null