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 #-----------------------------------------------------------------------
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
46 s,$SCRATCH_MNT,[SCR_MNT],;
47 s,$SCRATCH_DEV,[SCR_DEV],;
51 # real QA test starts here
53 _supported_os Linux #IRIX
61 echo; echo "### create files, setting up ownership (type=$type)"
62 touch $SCRATCH_MNT/file{1,2} 2>/dev/null
63 chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
64 chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
65 chmod 777 $SCRATCH_MNT 2>/dev/null
70 echo "### some buffered IO (type=$type)"
71 echo "--- initiating IO..." >>$seq.full
72 # Firstly fit below block soft limit
74 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 900k' -c fsync \
75 $SCRATCH_MNT/file1" 2>&1 >>$seq.full | tee -a $seq.full
76 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
77 # Secondly overcome block soft limit
78 echo "Rewrite 1001k..."
79 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1001k' -c fsync \
80 $SCRATCH_MNT/file1" 2>&1 >>$seq.full | tee -a $seq.full
81 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
82 # Now try to overcome block hardlimit
84 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1000k' -c fsync \
85 $SCRATCH_MNT/file2" 2>&1 >>$seq.full | tee -a $seq.full
86 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
87 # Now sleep for grace time and check that softlimit got enforced
90 su $qa_user -c "$XFS_IO_PROG -F -c 'truncate 0' -c 'pwrite 0 4096' \
91 $SCRATCH_MNT/file2" 2>&1 >>$seq.full | tee -a $seq.full
92 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
93 # And now the softlimit test for inodes
94 # First reset space limits so that we don't have problems with
95 # space reservations on XFS
96 setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
98 su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
99 2>&1 >>$seq.full | filter_scratch | tee -a $seq.full
100 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
101 # Try to exceed inode hardlimit
103 su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
104 2>&1 >>$seq.full | filter_scratch | tee -a $seq.full
105 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
106 # Wait and check grace time enforcement
107 rm -f $SCRATCH_MNT/file5 >>$seq.full 2>&1
110 su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seq.full |
111 filter_scratch | tee -a $seq.full
112 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
113 echo "--- completed IO ($type)" >>$seq.full
118 rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
121 # real QA test starts here
126 _scratch_mkfs >> $seq.full 2>&1
127 _scratch_mount "-o usrquota,grpquota"
128 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
129 quotaon $SCRATCH_MNT 2>/dev/null
130 setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT
131 setquota -u -t $grace $grace $SCRATCH_MNT
132 setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT
133 setquota -g -t $grace $grace $SCRATCH_MNT
136 echo; echo "### test user limit enforcement"
137 _scratch_mount "-o usrquota"
138 quotaon $SCRATCH_MNT 2>/dev/null
143 umount $SCRATCH_DEV 2>/dev/null
145 echo; echo "### test group limit enforcement"
146 _scratch_mount "-o grpquota"
147 quotaon $SCRATCH_MNT 2>/dev/null
152 umount $SCRATCH_DEV 2>/dev/null