Remove test 133 from auto group.
[xfstests-dev.git] / 107
1 #! /bin/sh
2 # FS QA Test No. 107
3 #
4 # Project quota.
5 # Use of "sync" mount option here is an attempt to get deterministic
6 # allocator behaviour.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
10 #-----------------------------------------------------------------------
11 #
12 # creator
13 owner=nathans@sgi.com
14
15 seq=`basename $0`
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
22
23 # get standard environment, filters and checks
24 . ./common.rc
25 . ./common.filter
26 . ./common.quota
27
28 filter_xfs_quota()
29 {
30         perl -ne "
31 s,$target,[TARGET],;
32 s,$tmp.projects,[PROJECTS_FILE],;
33 s,$SCRATCH_MNT,[SCR_MNT],;
34 s,$SCRATCH_DEV,[SCR_DEV],;
35 s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
36 s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
37         print;"
38 }
39
40 _supported_fs xfs
41 _supported_os Linux #IRIX
42 _require_scratch
43 _require_quota
44 _require_prjquota
45
46 # real QA test starts here
47 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
48 cat $tmp.mkfs >$seq.full
49 . $tmp.mkfs
50
51 # setup a default run
52 if [ -z "$MOUNT_OPTIONS" ]; then
53         export MOUNT_OPTIONS="-o pquota,sync"
54 else
55         export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
56 fi
57
58 _qmount
59 src/feature -p $SCRATCH_MNT && _notrun "Cannot run without project quota"
60
61 echo "### create projects file"
62 rm -f $tmp.projects
63 target=$SCRATCH_MNT/project
64 echo "6:$target" | tee -a $seq.full > $tmp.projects
65
66 echo "### populate filesystem"
67 mkdir $target           || exit
68 FSSTRESS_AVOID="$FSSTRESS_AVOID -fmknod=0 -fsymlink=0"
69 $FSSTRESS_PROG -s 0xfeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
70 $FSSTRESS_PROG -s 0xbabe -m8 -z -p4 -n500 -fsetxattr=250 -fchown=250 -d $target
71
72 QARGS="-x -D $tmp.projects -P /dev/null $SCRATCH_MNT"
73
74 echo "### initial report"
75 xfs_quota -c 'quot -p' -c 'quota -ip 6' $QARGS | filter_xfs_quota
76
77 echo "### check the project, should give warnings"
78 xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
79
80 echo "### recursively setup the project"
81 xfs_quota -c 'project -s 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
82 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
83
84 echo "### check the project, should give no warnings now"
85 xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
86
87 echo "### deny a hard link - wrong project ID"
88 rm -f $SCRATCH_MNT/outer $target/inner
89 $XFS_IO_PROG -f -c 'chproj 789' $SCRATCH_MNT/outer
90 ln $SCRATCH_MNT/outer $target/inner 2>/dev/null
91 if [ $? -eq 0 ]; then
92         echo hard link succeeded
93         ls -ld $SCRATCH_MNT/outer $target/inner
94 else
95         echo hard link failed
96 fi
97 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
98
99 echo "### allow a hard link - right project ID"
100 $XFS_IO_PROG -c 'chproj 6' $SCRATCH_MNT/outer
101 ln $SCRATCH_MNT/outer $target/inner
102 if [ $? -eq 0 ]; then
103         echo hard link succeeded
104 else
105         echo hard link failed
106         ls -ld $SCRATCH_MNT/outer $target/inner
107 fi
108 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
109
110 echo "### recursively clear the project"
111 xfs_quota -c 'project -C 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
112 #no output...
113 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
114
115 status=0
116 exit