Skip to contentSkip to conversation

Quota tests for XFSQA

PATCH In review Jan Kara 2 participants 5 messages May 18, 2010 – May 19, 2010

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

Hi,

in this series are three tests I have written (basically gathered from
various scripts) for XFSQA. The test quota accounting and also limits basic enforcement for VFS quotas (i.e. mainly ext? filesystems). Could the tests be included?

I'd like to add two more tests (fsstress running under 'nobody' with quota limits tightly set so that we get often EDQUOT failures) and a test where setquota would be stressing addition and removal of quota structures. Hopefully I'll get to it later this week.

Honza

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

author
#1 lore raw

PATCH 1/3 Test basic quota enforcement

Add a test which checks whether basic quota enforcement works.

---
 230     |  149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 230.out |  131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 group   |    1 +
 3 files changed, 281 insertions(+), 0 deletions(-)
 create mode 100755 230
 create mode 100644 230.out
230 new file +149 -0
new file mode 100755
index 0000000..e4ef657
@@ -0,0 +1,149 @@
+#! /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
[email protected]
+
+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
+
+test_files()
+{
+	echo; echo "### create files, setting up ownership (type=$type)"
+	rm -f $SCRATCH_MNT/file{1,2,3,4}
+	touch $SCRATCH_MNT/file{1,2}
+	chown $user $SCRATCH_MNT/file{1,2}
+	chgrp $group $SCRATCH_MNT/file{1,2}
+	chmod 777 $SCRATCH_MNT
+}
+
+test_enforcement()
+{
+	echo "### some buffered IO (type=$type)"
+	echo "--- initiating IO..." >>$seq.full
+	# Firstly fit below block soft limit
+	sudo -u $user $XFS_IO_PROG -F -c 'pwrite 0 4096' -c 'fsync' \
+			$SCRATCH_MNT/file1 2>&1 >>$seq.full | tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	# Secondly overcome block soft limit
+	sudo -u $user $XFS_IO_PROG -F -c 'pwrite 0 4097' -c 'fsync' \
+			$SCRATCH_MNT/file1 2>&1 >>$seq.full | tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	# Now try to overcome block hardlimit
+	sudo -u $user $XFS_IO_PROG -F -c 'pwrite 0 4097' -c 'fsync' \
+			$SCRATCH_MNT/file2 2>&1 >>$seq.full | tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	# Now sleep for grace time and check that softlimit got enforced
+	sleep $grace
+	sudo -u $user $XFS_IO_PROG -F -c 'truncate 0' -c 'pwrite 0 1' \
+			$SCRATCH_MNT/file2 2>&1 >>$seq.full | tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	# And now the softlimit test for inodes
+	sudo -u $user touch $SCRATCH_MNT/file3 2>&1 >>$seq.full |
+							tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	# Try to exceed inode hardlimit
+	sudo -u $user touch $SCRATCH_MNT/file4 $SCRATCH_MNT/file5 2>&1 \
+			>>$seq.full | tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	# Wait and check grace time enforcement
+	rm -f $SCRATCH_MNT/file4 >>$seq.full 2>&1
+	sleep $grace
+	sudo -u $user touch $SCRATCH_MNT/file4 2>&1 >>$seq.full |
+			tee -a $seq.full
+	repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
+	echo "--- completed IO ($type)" >>$seq.full
+}
+
+# real QA test starts here
+rm -f $seq.full
+
+user=nobody
+group=`sudo -u $user id -g`
+grace=2
+
+umount $SCRATCH_DEV 2>/dev/null
+_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 $user 4 12 2 4 $SCRATCH_MNT
+setquota -u -t $grace $grace $SCRATCH_MNT
+setquota -g $group 4 12 2 4 $SCRATCH_MNT
+setquota -g -t $grace $grace $SCRATCH_MNT
+umount $SCRATCH_DEV
+
+echo; echo "### test user limit enforcement"
+export MOUNT_OPTIONS="-o usrquota"
+_qmount
+quotaon $SCRATCH_MNT 2>/dev/null
+type=u
+test_files
+test_enforcement
+umount $SCRATCH_DEV 2>/dev/null
+
+echo; echo "### test group limit enforcement"
+export MOUNT_OPTIONS="-o grpquota"
+_qmount
+quotaon $SCRATCH_MNT 2>/dev/null
+type=g
+test_files
+test_enforcement
+umount $SCRATCH_DEV 2>/dev/null
+
+status=0
+exit
230.out new file +131 -0

131 lines not on this page · raw message

group +1 -0
index 2c1ac50..441e0e9 100644
@@ -343,3 +343,4 @@ deprecated
 227 auto fsr
 228 rw auto prealloc quick
 229 auto rw
+230 auto quota quick
Signature · 6 lines
1.6.4.2

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw

Re: [PATCH 1/3] Test basic quota enforcement

Quoted 1 line · Jan Kara

Add a test which checks whether basic quota enforcement works.

Couple of quick things:

- we have ${qa_user} for running stuff under a specific user
- sudo is not installed or configured for this sort of usage on many systems - typically su is used instead (e.g. see test 193)

230 line 119

Quoted 8 lines
230 new file +8 -0
+# real QA test starts here
+rm -f $seq.full
+
+user=nobody
+group=`sudo -u $user id -g`
+grace=2
+
+umount $SCRATCH_DEV 2>/dev/null

The scratch device should already be unmounted. if it isn't something went wrong in a previous test and unmounting it here isn't going to help.

230 line 132

Quoted 13 lines
230 new file +13 -0
+_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 $user 4 12 2 4 $SCRATCH_MNT
+setquota -u -t $grace $grace $SCRATCH_MNT
+setquota -g $group 4 12 2 4 $SCRATCH_MNT
+setquota -g -t $grace $grace $SCRATCH_MNT
+umount $SCRATCH_DEV
+
+echo; echo "### test user limit enforcement"
+export MOUNT_OPTIONS="-o usrquota"
+_qmount

That will overwrite any mount options specified on the command line. perhaps better is to use:

scratch_mount -o usrquota

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#3 lore raw

PATCH 2/3 Add test of quota accounting using fsx

In reply to Jan Kara

Run fsx (and also several fsx threads in parallel) and verify that quota accounting is correct after they finish.

---
 231     |  138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 231.out |   10 +++++
 group   |    1 +
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100755 231
 create mode 100644 231.out
231 new file +138 -0
new file mode 100755
index 0000000..fd4dac2
@@ -0,0 +1,138 @@
+#! /bin/bash
+# FSQA Test No. 231
+#
+# Run fsx with quotas enabled and verify accounted quotas in the end
+#
+# Derived from test 127
+#-----------------------------------------------------------------------
+# Copyright (c) 2006 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
[email protected]
+
+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
+
+FSX_FILE_SIZE=64000000
+FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -S 191110531 -N 100000"
+
+filter_scratch()
+{
+        perl -ne "
+s,$SCRATCH_MNT,[SCR_MNT],;
+s,$SCRATCH_DEV,[SCR_DEV],;
+        print;"
+}
+
+check_usage()
+{
+	quotaon -f -u -g $SCRATCH_MNT 2>/dev/null
+	repquota -u -g -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }' >$tmp.orig
+	quotacheck -u -g $SCRATCH_MNT 2>/dev/null
+	repquota -u -g -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }' >$tmp.checked
+	quotaon -u -g $SCRATCH_MNT 2>/dev/null
+	diff $tmp.orig $tmp.checked
+}
+
+_fsx()
+{
+	tasks=$1
+	echo "=== FSX Standard Mode, Memory Mapping, $tasks Tasks ==="
+	for (( i = 1; i <= $tasks; i++ )); do
+		sudo -u nobody ltp/fsx $FSX_ARGS $SCRATCH_MNT/fsx_file$i \
+			>$tmp.output$i 2>&1 &
+	done
+
+	for (( i = 1; i <= $tasks; i++ )); do
+		if ! wait %$i; then
+			cat $tmp.output$i
+			wait
+			return 1
+		fi
+		$XFS_IO_PROG -F -c 'fsync' $SCRATCH_MNT/fsx_file$i
+		cat $tmp.output$i
+	done
+	return 0
+}
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+
+umount $SCRATCH_DEV 2>/dev/null
+_scratch_mkfs >> $seq.full 2>&1
+_scratch_mount "-o usrquota,grpquota"
+chmod 777 $SCRATCH_MNT
+quotacheck -u -g $SCRATCH_MNT 2>/dev/null
+quotaon -u -g $SCRATCH_MNT 2>/dev/null
+
+if ! _fsx 1; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+if ! check_usage; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+if ! _fsx 4; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+if ! check_usage; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+#flush cache after write
+FSX_ARGS="-f $FSX_ARGS"
+if ! _fsx 1; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+if ! check_usage; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+umount $SCRATCH_DEV 2>/dev/null
+status=0
+exit
231.out new file +10 -0
new file mode 100644
index 0000000..2f2d072
@@ -0,0 +1,10 @@
+QA output created by 231
+=== FSX Standard Mode, Memory Mapping, 1 Tasks ===
+All operations completed A-OK!
+=== FSX Standard Mode, Memory Mapping, 4 Tasks ===
+All operations completed A-OK!
+All operations completed A-OK!
+All operations completed A-OK!
+All operations completed A-OK!
+=== FSX Standard Mode, Memory Mapping, 1 Tasks ===
+All operations completed A-OK!
group +1 -0
index 441e0e9..6b59c69 100644
@@ -344,3 +344,4 @@ deprecated
 228 rw auto prealloc quick
 229 auto rw
 230 auto quota quick
+231 auto quota
Signature · 6 lines
1.6.4.2

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#4 lore raw

PATCH 3/3 Add quota test with fsstress

In reply to Jan Kara

Run fsstress and verify that quota accounting is correct after it finishes.

---
 232     |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 232.out |    6 +++
 group   |    1 +
 3 files changed, 124 insertions(+), 0 deletions(-)
 create mode 100755 232
 create mode 100644 232.out
232 new file +117 -0
new file mode 100755
index 0000000..064f07b
@@ -0,0 +1,117 @@
+#! /bin/bash
+# FSQA Test No. 232
+#
+# Run fsstress with quotas enabled and verify accounted quotas in the end
+#
+# Derived from test 231
+#-----------------------------------------------------------------------
+# Copyright (c) 2006 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
[email protected]
+
+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
+
+FSX_FILE_SIZE=64000000
+FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -S 191110531 -N 100000"
+
+filter_scratch()
+{
+        perl -ne "
+s,$SCRATCH_MNT,[SCR_MNT],;
+s,$SCRATCH_DEV,[SCR_DEV],;
+        print;"
+}
+
+check_usage()
+{
+	quotaon -f -u -g $SCRATCH_MNT 2>/dev/null
+	repquota -u -g -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }' | sort >$tmp.orig
+	quotacheck -u -g $SCRATCH_MNT 2>/dev/null
+	repquota -u -g -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
+	awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }' | sort >$tmp.checked
+	quotaon -u -g $SCRATCH_MNT 2>/dev/null
+	diff $tmp.orig $tmp.checked
+}
+
+_filter_num()
+{
+	tee -a $here/$seq.full |\
+	sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
+	    -e 's/[0-9][0-9]* paths/P paths/g' \
+	    -e 's/seed = [0-9][0-9]*/seed = S/'
+}
+
+_fsstress()
+{
+	echo ""
+	echo "Testing fsstress"
+	echo ""
+
+	out=$SCRATCH_MNT/fsstress.$$
+	count=2000
+	args="-n $count -d $out -p 7"
+
+	echo "fsstress $args" | sed -e "s#$out#outdir#"
+	if ! $FSSTRESS_PROG $args | _filter_num
+	then
+		echo "    fsstress $args returned $?"
+		cat $tmp.out | tee -a $here/$seq.full
+		status=1
+	fi
+}
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_quota
+
+umount $SCRATCH_DEV 2>/dev/null
+_scratch_mkfs >> $seq.full 2>&1
+_scratch_mount "-o usrquota,grpquota"
+chmod 777 $SCRATCH_MNT
+quotacheck -u -g $SCRATCH_MNT 2>/dev/null
+quotaon -u -g $SCRATCH_MNT 2>/dev/null
+
+if ! _fsstress; then
+	umount $SCRATCH_DEV 2>/dev/null
+	exit
+fi
+
+if ! check_usage; then
+	umount $SCRATCH_DEV 2>/dev/null
+	status=1
+	exit
+fi
+
+umount $SCRATCH_DEV 2>/dev/null
+status=0
+exit
232.out new file +6 -0
new file mode 100644
index 0000000..744192e
@@ -0,0 +1,6 @@
+QA output created by 232
+
+Testing fsstress
+
+fsstress -n 2000 -d outdir -p 7
+seed = S
group +1 -0
index 6b59c69..c8cd774 100644
@@ -345,3 +345,4 @@ deprecated
 229 auto rw
 230 auto quota quick
 231 auto quota
+232 auto quota
Signature · 6 lines
1.6.4.2

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs