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
43 # real QA test starts here
45 _supported_os Linux #IRIX
53 echo; echo "### create files, setting up ownership (type=$type)"
54 touch $SCRATCH_MNT/file{1,2} 2>/dev/null
55 chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
56 chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
57 chmod 777 $SCRATCH_MNT 2>/dev/null
62 echo "### some buffered IO (type=$type)"
63 echo "--- initiating IO..." >>$seq.full
64 # Firstly fit below block soft limit
66 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 900k' -c fsync \
67 $SCRATCH_MNT/file1" 2>&1 >>$seq.full | tee -a $seq.full
68 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
69 # Secondly overcome block soft limit
70 echo "Rewrite 1001k..."
71 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1001k' -c fsync \
72 $SCRATCH_MNT/file1" 2>&1 >>$seq.full | tee -a $seq.full
73 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
74 # Now try to overcome block hardlimit
76 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1000k' -c fsync \
77 $SCRATCH_MNT/file2" 2>&1 >>$seq.full | tee -a $seq.full
78 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
79 # Now sleep for grace time and check that softlimit got enforced
82 su $qa_user -c "$XFS_IO_PROG -F -c 'truncate 0' -c 'pwrite 0 4096' \
83 $SCRATCH_MNT/file2" 2>&1 >>$seq.full | tee -a $seq.full
84 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
85 # And now the softlimit test for inodes
86 # First reset space limits so that we don't have problems with
87 # space reservations on XFS
88 setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
90 su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
91 2>&1 >>$seq.full | _filter_scratch | tee -a $seq.full
92 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
93 # Try to exceed inode hardlimit
95 su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
96 2>&1 >>$seq.full | _filter_scratch | tee -a $seq.full
97 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
98 # Wait and check grace time enforcement
99 rm -f $SCRATCH_MNT/file5 >>$seq.full 2>&1
102 su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seq.full |
103 _filter_scratch | tee -a $seq.full
104 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1
105 echo "--- completed IO ($type)" >>$seq.full
110 rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
113 # real QA test starts here
118 _scratch_mkfs >> $seq.full 2>&1
119 _scratch_mount "-o usrquota,grpquota"
120 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
121 quotaon $SCRATCH_MNT 2>/dev/null
122 setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT
123 setquota -u -t $grace $grace $SCRATCH_MNT
124 setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT
125 setquota -g -t $grace $grace $SCRATCH_MNT
128 echo; echo "### test user limit enforcement"
129 _scratch_mount "-o usrquota"
130 quotaon $SCRATCH_MNT 2>/dev/null
135 umount $SCRATCH_DEV 2>/dev/null
137 echo; echo "### test group limit enforcement"
138 _scratch_mount "-o grpquota"
139 quotaon $SCRATCH_MNT 2>/dev/null
144 umount $SCRATCH_DEV 2>/dev/null