forked from amir73il/xfstests
/
107
executable file
·130 lines (111 loc) · 3.79 KB
/
107
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /bin/bash
# FS QA Test No. 107
#
# Project quota.
# Use of "sync" mount option here is an attempt to get deterministic
# allocator behaviour.
#
#-----------------------------------------------------------------------
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#-----------------------------------------------------------------------
#
# creator
owner=nathans@sgi.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.quota
filter_xfs_quota()
{
perl -ne "
s,$target,[TARGET],;
s,$tmp.projects,[PROJECTS_FILE],;
s,$SCRATCH_MNT,[SCR_MNT],;
s,$SCRATCH_DEV,[SCR_DEV],;
s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
print;"
}
_supported_fs xfs
_supported_os Linux #IRIX
_require_scratch
_require_xfs_quota
_require_prjquota
# real QA test starts here
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
cat $tmp.mkfs >$seq.full
. $tmp.mkfs
# setup a default run
if [ -z "$MOUNT_OPTIONS" ]; then
export MOUNT_OPTIONS="-o pquota,sync"
else
export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
fi
_qmount
src/feature -p $SCRATCH_MNT && _notrun "Cannot run without project quota"
echo "### create projects file"
rm -f $tmp.projects
target=$SCRATCH_MNT/project
echo "6:$target" | tee -a $seq.full > $tmp.projects
echo "### populate filesystem"
mkdir $target || exit
FSSTRESS_AVOID="$FSSTRESS_AVOID -fmknod=0 -fsymlink=0"
$FSSTRESS_PROG -s 0xfeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
$FSSTRESS_PROG -s 0xbabe -m8 -z -p4 -n500 -fsetxattr=250 -fchown=250 -d $target
QARGS="-x -D $tmp.projects -P /dev/null $SCRATCH_MNT"
echo "### initial report"
xfs_quota -c 'quot -p' -c 'quota -ip 6' $QARGS | filter_xfs_quota
echo "### check the project, should give warnings"
xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
echo "### recursively setup the project"
xfs_quota -c 'project -s 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
echo "### check the project, should give no warnings now"
xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
echo "### deny a hard link - wrong project ID"
rm -f $SCRATCH_MNT/outer $target/inner
$XFS_IO_PROG -f -c 'chproj 789' $SCRATCH_MNT/outer
ln $SCRATCH_MNT/outer $target/inner 2>/dev/null
if [ $? -eq 0 ]; then
echo hard link succeeded
ls -ld $SCRATCH_MNT/outer $target/inner
else
echo hard link failed
fi
xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
echo "### allow a hard link - right project ID"
$XFS_IO_PROG -c 'chproj 6' $SCRATCH_MNT/outer
ln $SCRATCH_MNT/outer $target/inner
if [ $? -eq 0 ]; then
echo hard link succeeded
else
echo hard link failed
ls -ld $SCRATCH_MNT/outer $target/inner
fi
xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
echo "### recursively clear the project"
xfs_quota -c 'project -C 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
#no output...
xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
status=0
exit