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
51 echo; echo "### create files, setting up ownership (type=$type)"
52 touch $SCRATCH_MNT/file{1,2} 2>/dev/null
53 chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
54 chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
55 chmod 777 $SCRATCH_MNT 2>/dev/null
60 echo "### some buffered IO (type=$type)"
61 echo "--- initiating IO..." >>$seqres.full
62 # Firstly fit below block soft limit
64 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 900k' -c fsync \
65 $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | \
66 _filter_xfs_io_error | 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 | \
72 _filter_xfs_io_error | tee -a $seqres.full
73 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
74 # Now try to overcome block hardlimit
76 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 1000k' -c fsync \
77 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | \
78 _filter_xfs_io_error | 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 -c 'truncate 0' -c 'pwrite 0 4096' \
84 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | \
85 _filter_xfs_io_error | tee -a $seqres.full
86 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
87 # And now the softlimit test for inodes
88 # First reset space limits so that we don't have problems with
89 # space reservations on XFS
90 setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
92 su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
93 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
94 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
95 # Try to exceed inode hardlimit
97 su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
98 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
99 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
100 # Wait and check grace time enforcement
101 rm -f $SCRATCH_MNT/file5 >>$seqres.full 2>&1
104 su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full |
105 _filter_scratch | tee -a $seqres.full
106 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
107 echo "--- completed IO ($type)" >>$seqres.full
112 rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
115 # real QA test starts here
120 _scratch_mkfs >> $seqres.full 2>&1
121 _scratch_mount "-o usrquota,grpquota"
122 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
123 quotaon $SCRATCH_MNT 2>/dev/null
124 setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT
125 setquota -u -t $grace $grace $SCRATCH_MNT
126 setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT
127 setquota -g -t $grace $grace $SCRATCH_MNT
130 echo; echo "### test user limit enforcement"
131 _scratch_mount "-o usrquota"
132 quotaon $SCRATCH_MNT 2>/dev/null
137 _scratch_unmount 2>/dev/null
139 echo; echo "### test group limit enforcement"
140 _scratch_mount "-o grpquota"
141 quotaon $SCRATCH_MNT 2>/dev/null
146 _scratch_unmount 2>/dev/null