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 seqres=$RESULT_DIR/$seq
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
44 # real QA test starts here
46 _supported_os Linux #IRIX
54 echo; echo "### create files, setting up ownership (type=$type)"
55 touch $SCRATCH_MNT/file{1,2} 2>/dev/null
56 chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
57 chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
58 chmod 777 $SCRATCH_MNT 2>/dev/null
63 echo "### some buffered IO (type=$type)"
64 echo "--- initiating IO..." >>$seqres.full
65 # Firstly fit below block soft limit
67 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 900k' -c fsync \
68 $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | tee -a $seqres.full
69 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
70 # Secondly overcome block soft limit
71 echo "Rewrite 1001k..."
72 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1001k' -c fsync \
73 $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | tee -a $seqres.full
74 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
75 # Now try to overcome block hardlimit
77 su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1000k' -c fsync \
78 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | tee -a $seqres.full
79 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
80 # Now sleep for grace time and check that softlimit got enforced
83 su $qa_user -c "$XFS_IO_PROG -F -c 'truncate 0' -c 'pwrite 0 4096' \
84 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | tee -a $seqres.full
85 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
86 # And now the softlimit test for inodes
87 # First reset space limits so that we don't have problems with
88 # space reservations on XFS
89 setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
91 su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
92 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
93 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
94 # Try to exceed inode hardlimit
96 su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
97 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
98 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
99 # Wait and check grace time enforcement
100 rm -f $SCRATCH_MNT/file5 >>$seqres.full 2>&1
103 su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full |
104 _filter_scratch | tee -a $seqres.full
105 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
106 echo "--- completed IO ($type)" >>$seqres.full
111 rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
114 # real QA test starts here
119 _scratch_mkfs >> $seqres.full 2>&1
120 _scratch_mount "-o usrquota,grpquota"
121 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
122 quotaon $SCRATCH_MNT 2>/dev/null
123 setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT
124 setquota -u -t $grace $grace $SCRATCH_MNT
125 setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT
126 setquota -g -t $grace $grace $SCRATCH_MNT
129 echo; echo "### test user limit enforcement"
130 _scratch_mount "-o usrquota"
131 quotaon $SCRATCH_MNT 2>/dev/null
136 umount $SCRATCH_DEV 2>/dev/null
138 echo; echo "### test group limit enforcement"
139 _scratch_mount "-o grpquota"
140 quotaon $SCRATCH_MNT 2>/dev/null
145 umount $SCRATCH_DEV 2>/dev/null