From: Jan Kara Date: Tue, 18 May 2010 21:26:57 +0000 (+0200) Subject: Test basic quota enforcement X-Git-Tag: v1.1.0~162^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a764d7b39f6e7025d30f0180f4241b101799eb88;p=xfstests-dev.git Test basic quota enforcement Add a test which checks whether basic quota enforcement works. Signed-off-by: Jan Kara --- diff --git a/230 b/230 new file mode 100755 index 00000000..fb356731 --- /dev/null +++ b/230 @@ -0,0 +1,155 @@ +#! /bin/bash +# FS QA Test No. 230 +# +# Simple quota enforcement test. +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Jan Kara. All Rights Reserved. +# +# Based on test 219, +# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +#----------------------------------------------------------------------- +# +# creator +owner=jack@suse.cz + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.quota + +filter_scratch() +{ + perl -ne " +s,$SCRATCH_MNT,[SCR_MNT],; +s,$SCRATCH_DEV,[SCR_DEV],; + print;" +} + +# real QA test starts here +_supported_fs generic +_supported_os Linux #IRIX +_require_scratch +_require_quota +_require_user +_need_to_be_root + +test_files() +{ + echo; echo "### create files, setting up ownership (type=$type)" + touch $SCRATCH_MNT/file{1,2} 2>/dev/null + chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null + chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null + chmod 777 $SCRATCH_MNT 2>/dev/null +} + +test_enforcement() +{ + echo "### some buffered IO (type=$type)" + echo "--- initiating IO..." >>$seq.full + # Firstly fit below block soft limit + echo "Write 900k..." + su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 900k' -c fsync \ + $SCRATCH_MNT/file1" 2>&1 >>$seq.full | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + # Secondly overcome block soft limit + echo "Rewrite 1001k..." + su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1001k' -c fsync \ + $SCRATCH_MNT/file1" 2>&1 >>$seq.full | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + # Now try to overcome block hardlimit + echo "Write 1000k..." + su $qa_user -c "$XFS_IO_PROG -F -c 'pwrite 0 1000k' -c fsync \ + $SCRATCH_MNT/file2" 2>&1 >>$seq.full | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + # Now sleep for grace time and check that softlimit got enforced + sleep $((grace+1)) + echo "Write 4096..." + su $qa_user -c "$XFS_IO_PROG -F -c 'truncate 0' -c 'pwrite 0 4096' \ + $SCRATCH_MNT/file2" 2>&1 >>$seq.full | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + # And now the softlimit test for inodes + # First reset space limits so that we don't have problems with + # space reservations on XFS + setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT + echo "Touch 3+4" + su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \ + 2>&1 >>$seq.full | filter_scratch | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + # Try to exceed inode hardlimit + echo "Touch 5+6" + su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \ + 2>&1 >>$seq.full | filter_scratch | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + # Wait and check grace time enforcement + rm -f $SCRATCH_MNT/file5 >>$seq.full 2>&1 + sleep $((grace+1)) + echo "Touch 5" + su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seq.full | + filter_scratch | tee -a $seq.full + repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seq.full 2>&1 + echo "--- completed IO ($type)" >>$seq.full +} + +cleanup_files() +{ + rm -f $SCRATCH_MNT/file{1,2,3,4,5,6} +} + +# real QA test starts here +rm -f $seq.full + +grace=2 + +_scratch_mkfs >> $seq.full 2>&1 +_scratch_mount "-o usrquota,grpquota" +quotacheck -u -g $SCRATCH_MNT 2>/dev/null +quotaon $SCRATCH_MNT 2>/dev/null +setquota -u $qa_user 1000 2000 3 5 $SCRATCH_MNT +setquota -u -t $grace $grace $SCRATCH_MNT +setquota -g $qa_user 1000 2000 3 5 $SCRATCH_MNT +setquota -g -t $grace $grace $SCRATCH_MNT +umount $SCRATCH_DEV + +echo; echo "### test user limit enforcement" +_scratch_mount "-o usrquota" +quotaon $SCRATCH_MNT 2>/dev/null +type=u +test_files +test_enforcement +cleanup_files +umount $SCRATCH_DEV 2>/dev/null + +echo; echo "### test group limit enforcement" +_scratch_mount "-o grpquota" +quotaon $SCRATCH_MNT 2>/dev/null +type=g +test_files +test_enforcement +cleanup_files +umount $SCRATCH_DEV 2>/dev/null + +status=0 +exit diff --git a/230.out b/230.out new file mode 100644 index 00000000..10dd50ce --- /dev/null +++ b/230.out @@ -0,0 +1,33 @@ +QA output created by 230 + +### test user limit enforcement + +### create files, setting up ownership (type=u) +### some buffered IO (type=u) +Write 900k... +Rewrite 1001k... +Write 1000k... +pwrite64: Disk quota exceeded +Write 4096... +pwrite64: Disk quota exceeded +Touch 3+4 +Touch 5+6 +touch: cannot touch `[SCR_MNT]/file6': Disk quota exceeded +Touch 5 +touch: cannot touch `[SCR_MNT]/file5': Disk quota exceeded + +### test group limit enforcement + +### create files, setting up ownership (type=g) +### some buffered IO (type=g) +Write 900k... +Rewrite 1001k... +Write 1000k... +pwrite64: Disk quota exceeded +Write 4096... +pwrite64: Disk quota exceeded +Touch 3+4 +Touch 5+6 +touch: cannot touch `[SCR_MNT]/file6': Disk quota exceeded +Touch 5 +touch: cannot touch `[SCR_MNT]/file5': Disk quota exceeded diff --git a/group b/group index 2c1ac50c..441e0e96 100644 --- a/group +++ b/group @@ -343,3 +343,4 @@ deprecated 227 auto fsr 228 rw auto prealloc quick 229 auto rw +230 auto quota quick