1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2009 Eric Sandeen. All Rights Reserved.
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
#
# FS QA Test No. 219
#
# Simple quota accounting test for direct/buffered/mmap IO.
#
. ./common/preamble
_begin_fstest auto quota quick
# Import common functions.
. ./common/filter
. ./common/quota
# real QA test starts here
_supported_fs generic
_require_scratch
_require_quota
_require_user
_require_group
_require_odirect
test_files()
{
echo; echo "### create files, setting up ownership (type=$type)"
rm -f $SCRATCH_MNT/{buffer,direct,mmap}
touch $SCRATCH_MNT/{buffer,direct,mmap}
chown $qa_user $SCRATCH_MNT/{buffer,direct,mmap}
chgrp $qa_group $SCRATCH_MNT/{buffer,direct,mmap}
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
$here/src/lstat64 $file | head -2 | _filter_scratch
done
}
check_usage()
{
wroteblocks=$1
wrotefiles=$2
read id exceed blocks bsoft bhard inodes isoft ihard
if [ "$blocks" -lt "$wroteblocks" ]; then
echo "Too few blocks used (type=$type)"
# Save 5% for overhead of metadata or different block size
elif [ "$blocks" -gt $((wroteblocks+wroteblocks/20)) ]; then
echo "Too many blocks used (type=$type)"
elif [ "$inodes" != "$wrotefiles" ]; then
echo "Bad number of inodes used (type=$type)"
else
echo "Usage OK (type=$type)"
fi
}
test_accounting()
{
echo "### some controlled buffered, direct and mmapd IO (type=$type)"
echo "--- initiating parallel IO..." >>$seqres.full
# Small ios here because ext3 will account for indirect blocks too ...
# 48k will fit w/o indirect for 4k blocks (default blocksize)
$XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
$XFS_IO_PROG -c 'pwrite 0 48k' -d \
$SCRATCH_MNT/direct >>$seqres.full 2>&1 &
$XFS_IO_PROG -c 't 48k' -c 'mm -rw 0 48k' -c 'mw 0 48k' -c 'ms -s' \
$SCRATCH_MNT/mmap >>$seqres.full 2>&1 &
wait
echo "--- completed parallel IO ($type)" >>$seqres.full
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
$here/src/lstat64 $file | head -2 | _filter_scratch
done
if [ $type == 'u' ]; then
id=$qa_user
else
id=$qa_group
fi
repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
}
# real QA test starts here
_scratch_unmount 2>/dev/null
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount "-o usrquota,grpquota"
quotacheck -u -g $SCRATCH_MNT 2>/dev/null
quotaon $SCRATCH_MNT 2>/dev/null
_scratch_unmount
echo; echo "### test user accounting"
export MOUNT_OPTIONS="-o usrquota"
_qmount
quotaon $SCRATCH_MNT 2>/dev/null
type=u
test_files
test_accounting
_scratch_unmount 2>/dev/null
echo; echo "### test group accounting"
export MOUNT_OPTIONS="-o grpquota"
_qmount
quotaon $SCRATCH_MNT 2>/dev/null
type=g
test_files
test_accounting
_scratch_unmount 2>/dev/null
status=0
exit
|