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 | tee -a $seqres.full
66 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
67 # Secondly overcome block soft limit
68 echo "Rewrite 1001k..."
69 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 1001k' -c fsync \
70 $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | tee -a $seqres.full
71 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
72 # Now try to overcome block hardlimit
74 su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 1000k' -c fsync \
75 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | tee -a $seqres.full
76 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
77 # Now sleep for grace time and check that softlimit got enforced
80 su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 4096' \
81 $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | tee -a $seqres.full
82 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
83 # And now the softlimit test for inodes
84 # First reset space limits so that we don't have problems with
85 # space reservations on XFS
86 setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
88 su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
89 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
90 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
91 # Try to exceed inode hardlimit
93 su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
94 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
95 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
96 # Wait and check grace time enforcement
97 rm -f $SCRATCH_MNT/file5 >>$seqres.full 2>&1
100 su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full |
101 _filter_scratch | tee -a $seqres.full
102 repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
103 echo "--- completed IO ($type)" >>$seqres.full
108 rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
111 # real QA test starts here
116 _scratch_mkfs >> $seqres.full 2>&1
117 _scratch_mount "-o usrquota,grpquota"
118 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
119 quotaon $SCRATCH_MNT 2>/dev/null
120 setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT
121 setquota -u -t $grace $grace $SCRATCH_MNT
122 setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT
123 setquota -g -t $grace $grace $SCRATCH_MNT
126 echo; echo "### test user limit enforcement"
127 _scratch_mount "-o usrquota"
128 quotaon $SCRATCH_MNT 2>/dev/null
133 _scratch_unmount 2>/dev/null
135 echo; echo "### test group limit enforcement"
136 _scratch_mount "-o grpquota"
137 quotaon $SCRATCH_MNT 2>/dev/null
142 _scratch_unmount 2>/dev/null