3 #-----------------------------------------------------------------------
4 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #-----------------------------------------------------------------------
24 # Use of "sync" mount option here is an attempt to get deterministic
25 # allocator behaviour.
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
47 s,$tmp.projects,[PROJECTS_FILE],;
48 s,$SCRATCH_MNT,[SCR_MNT],;
49 s,$SCRATCH_DEV,[SCR_DEV],;
50 s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
51 s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
56 _supported_os Linux #IRIX
61 # real QA test starts here
62 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
63 cat $tmp.mkfs >$seq.full
67 if [ -z "$MOUNT_OPTIONS" ]; then
68 export MOUNT_OPTIONS="-o pquota,sync"
70 export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
74 src/feature -p $SCRATCH_MNT && _notrun "Cannot run without project quota"
76 echo "### create projects file"
78 target=$SCRATCH_MNT/project
79 echo "6:$target" | tee -a $seq.full > $tmp.projects
81 echo "### populate filesystem"
83 FSSTRESS_AVOID="$FSSTRESS_AVOID -fmknod=0 -fsymlink=0"
84 $FSSTRESS_PROG -s 0xfeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
85 $FSSTRESS_PROG -s 0xbabe -m8 -z -p4 -n500 -fsetxattr=250 -fchown=250 -d $target
87 QARGS="-x -D $tmp.projects -P /dev/null $SCRATCH_MNT"
89 echo "### initial report"
90 xfs_quota -c 'quot -p' -c 'quota -ip 6' $QARGS | filter_xfs_quota
92 echo "### check the project, should give warnings"
93 xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
95 echo "### recursively setup the project"
96 xfs_quota -c 'project -s 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
97 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
99 echo "### check the project, should give no warnings now"
100 xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
102 echo "### deny a hard link - wrong project ID"
103 rm -f $SCRATCH_MNT/outer $target/inner
104 $XFS_IO_PROG -f -c 'chproj 789' $SCRATCH_MNT/outer
105 ln $SCRATCH_MNT/outer $target/inner 2>/dev/null
106 if [ $? -eq 0 ]; then
107 echo hard link succeeded
108 ls -ld $SCRATCH_MNT/outer $target/inner
110 echo hard link failed
112 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
114 echo "### allow a hard link - right project ID"
115 $XFS_IO_PROG -c 'chproj 6' $SCRATCH_MNT/outer
116 ln $SCRATCH_MNT/outer $target/inner
117 if [ $? -eq 0 ]; then
118 echo hard link succeeded
120 echo hard link failed
121 ls -ld $SCRATCH_MNT/outer $target/inner
123 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
125 echo "### recursively clear the project"
126 xfs_quota -c 'project -C 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
128 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota