4 # Simple quota enforcement test.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2010 Jan Kara. All Rights Reserved.
10 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 # real QA test starts here
44 _supported_os Linux #IRIX
52 echo; echo "### create files, setting up ownership (type=$type)"
53 touch $SCRATCH_MNT/file{1,2} 2>/dev/null
54 chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
55 chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
56 chmod 777 $SCRATCH_MNT 2>/dev/null
61 echo "### some buffered IO (type=$type)"
62 echo "--- initiating IO..." >>$seqres.full
63 # Firstly fit below block soft limit
65 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 900k' -c fsync \
66 $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | tee -a $seqres.full
67 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
68 # Secondly overcome block soft limit
69 echo "Rewrite 1001k..."
70 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 1001k' -c fsync \
71 $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | tee -a $seqres.full
72 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
73 # Now try to overcome block hardlimit
75 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 1000k' -c fsync \
76 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | tee -a $seqres.full
77 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
78 # Now sleep for grace time and check that softlimit got enforced
81 su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 4096' \
82 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | tee -a $seqres.full
83 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
84 # And now the softlimit test for inodes
85 # First reset space limits so that we don't have problems with
86 # space reservations on XFS
87 setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
89 su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
90 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
91 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
92 # Try to exceed inode hardlimit
94 su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
95 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
96 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
97 # Wait and check grace time enforcement
98 rm -f $SCRATCH_MNT/file5 >>$seqres.full 2>&1
101 su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full |
102 _filter_scratch | tee -a $seqres.full
103 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
104 echo "--- completed IO ($type)" >>$seqres.full
109 rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
112 # real QA test starts here
117 _scratch_mkfs >> $seqres.full 2>&1
118 _scratch_mount "-o usrquota,grpquota"
119 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
120 quotaon $SCRATCH_MNT 2>/dev/null
121 setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT
122 setquota -u -t $grace $grace $SCRATCH_MNT
123 setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT
124 setquota -g -t $grace $grace $SCRATCH_MNT
127 echo; echo "### test user limit enforcement"
128 _scratch_mount "-o usrquota"
129 quotaon $SCRATCH_MNT 2>/dev/null
134 umount $SCRATCH_DEV 2>/dev/null
136 echo; echo "### test group limit enforcement"
137 _scratch_mount "-o grpquota"
138 quotaon $SCRATCH_MNT 2>/dev/null
143 umount $SCRATCH_DEV 2>/dev/null