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
110
111
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
#
# FS QA Test No. 108
#
# Simple quota accounting test for direct/buffered/mmap IO.
#
. ./common/preamble
_begin_fstest quota auto quick
# Import common functions.
. ./common/filter
. ./common/quota
# real QA test starts here
_supported_fs xfs
_require_scratch
_require_xfs_quota
_require_xfs_io_command "syncfs"
test_files()
{
echo; echo "### create files, setting up ownership (type=$type)"
rm -f $SCRATCH_MNT/{buffer,direct,mmap}
$XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
$here/src/lstat64 $file | head -3 | _filter_scratch
$XFS_IO_PROG -c lsproj $file
done
}
# Some filesystem configurations fragment the file mapping more than others,
# which leads to the quota block counts being slightly higher than the 48MB
# written.
filter_quota()
{
sed -e 's/48\.[01]M/48M/g' | _filter_quota
}
test_accounting()
{
echo "### some controlled buffered, direct and mmapd IO (type=$type)"
echo "--- initiating parallel IO..." >>$seqres.full
$XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
$XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
$SCRATCH_MNT/direct >>$seqres.full 2>&1 &
$XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -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 -3 | _filter_scratch
done
$XFS_IO_PROG -c syncfs $SCRATCH_MNT
$XFS_QUOTA_PROG -c "quota -hnb -$type $id" $QARGS | filter_quota
$XFS_QUOTA_PROG -c "quota -hni -$type $id" $QARGS | filter_quota
$XFS_QUOTA_PROG -c "quota -hnr -$type $id" $QARGS | filter_quota
}
export MOUNT_OPTIONS="-opquota"
_scratch_mkfs_xfs >> $seqres.full
_qmount
_require_prjquota $SCRATCH_DEV
# real QA test starts here
rm -f $tmp.projects $seqres.full
_scratch_unmount 2>/dev/null
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
cat $tmp.mkfs >>$seqres.full
_scratch_mount
uid=1
gid=2
prid=3
export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
_scratch_unmount
echo; echo "### test user accounting"
export MOUNT_OPTIONS="-ouquota"
_qmount
type=u
id=$uid
test_files
test_accounting
_scratch_unmount 2>/dev/null
echo; echo "### test group accounting"
export MOUNT_OPTIONS="-ogquota"
_qmount
type=g
id=$gid
test_files
test_accounting
_scratch_unmount 2>/dev/null
#echo; echo "### test project accounting"
export MOUNT_OPTIONS="-opquota"
_qmount
type=p
id=$prid
test_files
test_accounting
_scratch_unmount 2>/dev/null
status=0
exit
|