Skip to contentSkip to conversation

generic: soft quota limits testing within grace time

PATCH Superseded Zorro Lang 3 participants 7 messages May 12, 2022 – May 13, 2022

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v3 1/2 generic: soft quota limits testing within grace time

After soft limits are exceeded, within the grace time, fs quota should allow more space allocation before exceeding hard limits, even if allocating many small files.

This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts when we send warnings"). And will help to expose later behavior changes on this side.

---

According to the review points of:
https://lore.kernel.org/fstests/20220511163806.uc4z7td2remhdru3@zlang-mailbox/T/#m23940b47261165a0442c7ae1eb4d96a1489a2935
V3 did below changes:
1) fix some comments description
2) add a few hard limit test
3) And bring in [PATCH 2/2], to help g/603 to use the common functions of this patch.

Thanks,
Zorro

 common/quota          | 48 +++++++++++++++++++++
 tests/generic/999     | 99 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  2 +
 3 files changed, 149 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out
common/quota +48 -0
index 7fa1a61a..67698f74 100644
@@ -351,5 +351,53 @@ _qsetup()
 	echo "Using type=$type id=$id" >> $seqres.full
 }
 
+# Help to create project quota on directory, works for xfs and other fs.
+# Usage: _create_project_quota <dirname> <projid> [name]
+# Although the [name] is optional, better to specify it if need a fixed name.
+_create_project_quota()
+{
+	local prjdir=$1
+	local id=$2
+	local name=$3
+
+	if [ -z "$name" ];then
+		name=`echo $projdir | tr \/ \_`
+	fi
+
+	rm -rf $prjdir
+	mkdir $prjdir
+	chmod ugo+rwx $prjdir
+
+	if [ -f /etc/projects -a ! -f $tmp.projects.bk ];then
+		cat /etc/projects > $tmp.projects.bk
+		echo >/etc/projects
+	fi
+	if [ -f /etc/projid -a ! -f $tmp.projid.bk ];then
+		cat /etc/projid > $tmp.projid.bk
+		echo >/etc/projid
+	fi
+
+	cat >>/etc/projects <<EOF
+$id:$prjdir
+EOF
+	cat >>/etc/projid <<EOF
+$name:$id
+EOF
+	$XFS_IO_PROG -r -c "chproj $id" -c "chattr +P" $prjdir
+}
+
+# If you've called _create_project_quota, then use this function in _cleanup
+_restore_project_quota()
+{
+	if [ -f $tmp.projects.bk ];then
+		cat $tmp.projects.bk > /etc/projects && \
+			rm -f $tmp.projects.bk
+	fi
+	if [ -f $tmp.projid.bk ];then
+		cat $tmp.projid.bk > /etc/projid && \
+			rm -f $tmp.projid.bk
+	fi
+}
+
 # make sure this script returns success
 /bin/true
tests/generic/999 new file +99 -0

99 lines not on this page · raw message

tests/generic/999.out new file +2 -0
new file mode 100644
index 00000000..3b276ca8
@@ -0,0 +1,2 @@
+QA output created by 999
+Silence is golden
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v3 2/2 generic/603: use project quota create and restore common helpers

As common/quota has _create_project_quota and _restore_project_quota helpers now, so replace local similar functions with them.

---
 tests/generic/603 | 36 ++----------------------------------
 1 file changed, 2 insertions(+), 34 deletions(-)
tests/generic/603 +2 -34
index b362a3d0..08ddcbf2 100755
@@ -13,7 +13,7 @@ _begin_fstest auto quick quota
 # Override the default cleanup function.
 _cleanup()
 {
-	restore_project
+	_restore_project_quota
 	cd /
 	rm -f $tmp.*
 }
@@ -22,38 +22,6 @@ _cleanup()
 . ./common/filter
 . ./common/quota
 
-require_project()
-{
-	rm -f $tmp.projects $tmp.projid
-	if [ -f /etc/projects ];then
-		cat /etc/projects > $tmp.projects
-	fi
-	if [ -f /etc/projid ];then
-		cat /etc/projid > $tmp.projid
-	fi
-
-	cat >/etc/projects <<EOF
-100:$SCRATCH_MNT/t
-EOF
-	cat >/etc/projid <<EOF
-$qa_user:100
-EOF
-	PROJECT_CHANGED=1
-}
-
-restore_project()
-{
-	if [ "$PROJECT_CHANGED" = "1" ];then
-		rm -f /etc/projects /etc/projid
-		if [ -f $tmp.projects ];then
-			cat $tmp.projects > /etc/projects
-		fi
-		if [ -f $tmp.projid ];then
-			cat $tmp.projid > /etc/projid
-		fi
-	fi
-}
-
 init_files()
 {
 	local dir=$1
@@ -157,7 +125,7 @@ BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 rm -rf $SCRATCH_MNT/t
 mkdir $SCRATCH_MNT/t
 $XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
-require_project
+_create_project_quota $SCRATCH_MNT/t 100 $qa_user
 
 echo "### Set up different grace timers to each type of quota"
 UBGRACE=12
Signature · 1 line
2.31.1
Reviewed-by on v3 2/2
#2 lore raw

Re: [PATCH v3 2/2] generic/603: use project quota create and restore common helpers

Quoted 4 lines · Zorro Lang

As common/quota has _create_project_quota and _restore_project_quota helpers now, so replace local similar functions with them.

LGTM

--D

Quoted 68 lines
---
 tests/generic/603 | 36 ++----------------------------------
 1 file changed, 2 insertions(+), 34 deletions(-)
tests/generic/603 +2 -34
index b362a3d0..08ddcbf2 100755
@@ -13,7 +13,7 @@ _begin_fstest auto quick quota
 # Override the default cleanup function.
 _cleanup()
 {
-	restore_project
+	_restore_project_quota
 	cd /
 	rm -f $tmp.*
 }
@@ -22,38 +22,6 @@ _cleanup()
 . ./common/filter
 . ./common/quota
 
-require_project()
-{
-	rm -f $tmp.projects $tmp.projid
-	if [ -f /etc/projects ];then
-		cat /etc/projects > $tmp.projects
-	fi
-	if [ -f /etc/projid ];then
-		cat /etc/projid > $tmp.projid
-	fi
-
-	cat >/etc/projects <<EOF
-100:$SCRATCH_MNT/t
-EOF
-	cat >/etc/projid <<EOF
-$qa_user:100
-EOF
-	PROJECT_CHANGED=1
-}
-
-restore_project()
-{
-	if [ "$PROJECT_CHANGED" = "1" ];then
-		rm -f /etc/projects /etc/projid
-		if [ -f $tmp.projects ];then
-			cat $tmp.projects > /etc/projects
-		fi
-		if [ -f $tmp.projid ];then
-			cat $tmp.projid > /etc/projid
-		fi
-	fi
-}
-
 init_files()
 {
 	local dir=$1
@@ -157,7 +125,7 @@ BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 rm -rf $SCRATCH_MNT/t
 mkdir $SCRATCH_MNT/t
 $XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
-require_project
+_create_project_quota $SCRATCH_MNT/t 100 $qa_user
 
 echo "### Set up different grace timers to each type of quota"
 UBGRACE=12
Signature · 1 line
2.31.1
#3 lore raw
In reply to Zorro Lang
Quoted 152 lines · Zorro Lang

After soft limits are exceeded, within the grace time, fs quota should allow more space allocation before exceeding hard limits, even if allocating many small files.

This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts when we send warnings"). And will help to expose later behavior changes on this side.

---

According to the review points of:
https://lore.kernel.org/fstests/20220511163806.uc4z7td2remhdru3@zlang-mailbox/T/#m23940b47261165a0442c7ae1eb4d96a1489a2935
V3 did below changes:
1) fix some comments description
2) add a few hard limit test
3) And bring in [PATCH 2/2], to help g/603 to use the common functions of this patch.

Thanks,
Zorro

 common/quota          | 48 +++++++++++++++++++++
 tests/generic/999     | 99 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  2 +
 3 files changed, 149 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out
common/quota +48 -0
index 7fa1a61a..67698f74 100644
@@ -351,5 +351,53 @@ _qsetup()
 	echo "Using type=$type id=$id" >> $seqres.full
 }
 
+# Help to create project quota on directory, works for xfs and other fs.
+# Usage: _create_project_quota <dirname> <projid> [name]
+# Although the [name] is optional, better to specify it if need a fixed name.
+_create_project_quota()
+{
+	local prjdir=$1
+	local id=$2
+	local name=$3
+
+	if [ -z "$name" ];then
+		name=`echo $projdir | tr \/ \_`
+	fi
+
+	rm -rf $prjdir
+	mkdir $prjdir
+	chmod ugo+rwx $prjdir
+
+	if [ -f /etc/projects -a ! -f $tmp.projects.bk ];then
+		cat /etc/projects > $tmp.projects.bk
+		echo >/etc/projects
+	fi
+	if [ -f /etc/projid -a ! -f $tmp.projid.bk ];then
+		cat /etc/projid > $tmp.projid.bk
+		echo >/etc/projid
+	fi
+
+	cat >>/etc/projects <<EOF
+$id:$prjdir
+EOF
+	cat >>/etc/projid <<EOF
+$name:$id
+EOF
+	$XFS_IO_PROG -r -c "chproj $id" -c "chattr +P" $prjdir
+}
+
+# If you've called _create_project_quota, then use this function in _cleanup
+_restore_project_quota()
+{
+	if [ -f $tmp.projects.bk ];then
+		cat $tmp.projects.bk > /etc/projects && \
+			rm -f $tmp.projects.bk
+	fi
+	if [ -f $tmp.projid.bk ];then
+		cat $tmp.projid.bk > /etc/projid && \
+			rm -f $tmp.projid.bk
+	fi
+}
+
 # make sure this script returns success
 /bin/true
tests/generic/999 new file +59 -0
new file mode 100755
index 00000000..76d68df5
@@ -0,0 +1,99 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Red Hat Inc.  All Rights Reserved.
+#
+# FS QA Test No. 999
+#
+# Make sure filesystem quota works well, after soft limits are exceeded. The
+# fs quota should allow more space allocation before exceeding hard limits
+# and with in grace time.
+#
+# But different with other similar testing, this case tries to write many small
+# files, to cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts
+# when we send warnings"). If there's a behavior change some day, this case
+# might help to detect that too.
+#
+. ./common/preamble
+_begin_fstest auto quota
+
+# Override the default cleanup function.
+_cleanup()
+{
+	_restore_project_quota
+	cd /
+	rm -r -f $tmp.*
+}
+
+# Import common functions.
+. ./common/quota
+
+# real QA test starts here
+_supported_fs generic
+_require_scratch
+_require_quota
+_require_user
+_require_group
+
+# Make sure the kernel supports project quota
+_scratch_mkfs >$seqres.full 2>&1
+_scratch_enable_pquota
+_qmount_option "prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+exercise()
+{
+	local type=$1
+	local file=$SCRATCH_MNT/testfile
+
+	echo "= Test type=$type quota =" >>$seqres.full
+	_scratch_unmount
+	_scratch_mkfs >>$seqres.full 2>&1
+	if [ "$1" = "P" ];then
+		_scratch_enable_pquota
+	fi
+	_qmount
+	if [ "$1" = "P" ];then
+		_create_project_quota $SCRATCH_MNT/t 100 $qa_user
+		file=$SCRATCH_MNT/t/testfile
+	fi

tests/generic/999 line 69

Quoted 10 lines
tests/generic/999 new file +10 -0
+
+	setquota -${type} $qa_user 1M 200M 0 0 $SCRATCH_MNT
+	setquota -${type} -t 86400 86400 $SCRATCH_MNT
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+	# Exceed the soft quota limit a bit at first
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full 2>&1
+	# Write more data more times under soft quota limit exhausted condition,
+	# but not reach hard limit. To make sure each write won't trigger EDQUOT.
+	for ((i=1; i<=100; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full 2>&1

Hmm -- if pwrite or fsync hit an error, shouldn't we let that end up in 999.out so that the golden output diff fails?

tests/generic/999 line 81

Quoted 12 lines
tests/generic/999 new file +12 -0
+		if [ $? -ne 0 ];then
+			echo "Unexpected error (type=$type)!"
+			break
+		fi
+	done
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+
+	# As we've tested soft limit, now exceed the hard limit and give it a
+	# test in passing.
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" >>$seqres.full 2>&1
+	for ((i=1; i<=10; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" >>$seqres.full 2>&1

Don't we want to encode the actual error in the golden output?

--D

Quoted 29 lines
tests/generic/999 new file +18 -0
+		if [ $? -eq 0 ];then
+			echo "Unexpected success (type=$type)!"
+			break
+		fi
+	done
+}
+
+_qmount_option "usrquota"
+exercise u
+_qmount_option "grpquota"
+exercise g
+_qmount_option "prjquota"
+exercise P
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/generic/999.out new file +2 -0
new file mode 100644
index 00000000..3b276ca8
@@ -0,0 +1,2 @@
+QA output created by 999
+Silence is golden
Signature · 1 line
2.31.1
author
#4 lore raw
Quoted 30 lines · Darrick J. Wong
Quoted 29 lines · Zorro Lang

After soft limits are exceeded, within the grace time, fs quota should allow more space allocation before exceeding hard limits, even if allocating many small files.

This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts when we send warnings"). And will help to expose later behavior changes on this side.

---

According to the review points of:
https://lore.kernel.org/fstests/20220511163806.uc4z7td2remhdru3@zlang-mailbox/T/#m23940b47261165a0442c7ae1eb4d96a1489a2935
V3 did below changes:
1) fix some comments description
2) add a few hard limit test
3) And bring in [PATCH 2/2], to help g/603 to use the common functions of this patch.

Thanks,
Zorro

 common/quota          | 48 +++++++++++++++++++++
 tests/generic/999     | 99 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  2 +
 3 files changed, 149 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out

[snip]

Quoted 5 lines
Quoted 5 lines
tests/generic/999 new file +5 -0
+
+	setquota -${type} $qa_user 1M 200M 0 0 $SCRATCH_MNT
+	setquota -${type} -t 86400 86400 $SCRATCH_MNT
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+	# Exceed the soft quota limit a bit at first
Quoted 8 lines

tests/generic/999 line 69

Quoted 5 lines
tests/generic/999 new file +5 -0
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full 2>&1
+	# Write more data more times under soft quota limit exhausted condition,
+	# but not reach hard limit. To make sure each write won't trigger EDQUOT.
+	for ((i=1; i<=100; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full 2>&1

Hmm -- if pwrite or fsync hit an error, shouldn't we let that end up in 999.out so that the golden output diff fails?

Sure, will remove the "2>&1".

Quoted 15 lines

tests/generic/999 line 81

Quoted 13 lines
tests/generic/999 new file +12 -0
+		if [ $? -ne 0 ];then
+			echo "Unexpected error (type=$type)!"
+			break
+		fi
+	done
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+
+	# As we've tested soft limit, now exceed the hard limit and give it a
+	# test in passing.
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" >>$seqres.full 2>&1
+	for ((i=1; i<=10; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" >>$seqres.full 2>&1

Don't we want to encode the actual error in the golden output?

Hmm... due to I have to filter the ENOSPC or EDQUOT output again for project quota, as I did in generic/603 :-P Or put the that function into common/quota too.

Thanks,
Zorro

Quoted 33 lines

--D

Quoted 29 lines
tests/generic/999 new file +18 -0
+		if [ $? -eq 0 ];then
+			echo "Unexpected success (type=$type)!"
+			break
+		fi
+	done
+}
+
+_qmount_option "usrquota"
+exercise u
+_qmount_option "grpquota"
+exercise g
+_qmount_option "prjquota"
+exercise P
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/generic/999.out new file +2 -0
new file mode 100644
index 00000000..3b276ca8
@@ -0,0 +1,2 @@
+QA output created by 999
+Silence is golden
Signature · 1 line
2.31.1
#5 lore raw
Quoted 66 lines · Zorro Lang
Quoted 30 lines · Darrick J. Wong
Quoted 29 lines · Zorro Lang

After soft limits are exceeded, within the grace time, fs quota should allow more space allocation before exceeding hard limits, even if allocating many small files.

This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts when we send warnings"). And will help to expose later behavior changes on this side.

---

According to the review points of:
https://lore.kernel.org/fstests/20220511163806.uc4z7td2remhdru3@zlang-mailbox/T/#m23940b47261165a0442c7ae1eb4d96a1489a2935
V3 did below changes:
1) fix some comments description
2) add a few hard limit test
3) And bring in [PATCH 2/2], to help g/603 to use the common functions of this patch.

Thanks,
Zorro

 common/quota          | 48 +++++++++++++++++++++
 tests/generic/999     | 99 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  2 +
 3 files changed, 149 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out

[snip]

Quoted 5 lines
Quoted 5 lines
tests/generic/999 new file +5 -0
+
+	setquota -${type} $qa_user 1M 200M 0 0 $SCRATCH_MNT
+	setquota -${type} -t 86400 86400 $SCRATCH_MNT
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+	# Exceed the soft quota limit a bit at first
Quoted 8 lines

tests/generic/999 line 69

Quoted 5 lines
tests/generic/999 new file +5 -0
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full 2>&1
+	# Write more data more times under soft quota limit exhausted condition,
+	# but not reach hard limit. To make sure each write won't trigger EDQUOT.
+	for ((i=1; i<=100; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full 2>&1

Hmm -- if pwrite or fsync hit an error, shouldn't we let that end up in 999.out so that the golden output diff fails?

Sure, will remove the "2>&1".

Quoted 15 lines

tests/generic/999 line 81

Quoted 13 lines
tests/generic/999 new file +12 -0
+		if [ $? -ne 0 ];then
+			echo "Unexpected error (type=$type)!"
+			break
+		fi
+	done
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+
+	# As we've tested soft limit, now exceed the hard limit and give it a
+	# test in passing.
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" >>$seqres.full 2>&1
+	for ((i=1; i<=10; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" >>$seqres.full 2>&1

Don't we want to encode the actual error in the golden output?

Quoted 3 lines

Hmm... due to I have to filter the ENOSPC or EDQUOT output again for project quota, as I did in generic/603 :-P Or put the that function into common/quota too.

I think it'd be fine if the golden output contained:

pwrite: Insufficient quota
pwrite: Insufficient quota
pwrite: Not enough space

for each of the user/group/project quota tests. Or did I misunderstand?

--D

Quoted 36 lines

Thanks,
Zorro

Quoted 33 lines

--D

Quoted 29 lines
tests/generic/999 new file +18 -0
+		if [ $? -eq 0 ];then
+			echo "Unexpected success (type=$type)!"
+			break
+		fi
+	done
+}
+
+_qmount_option "usrquota"
+exercise u
+_qmount_option "grpquota"
+exercise g
+_qmount_option "prjquota"
+exercise P
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/generic/999.out new file +2 -0
new file mode 100644
index 00000000..3b276ca8
@@ -0,0 +1,2 @@
+QA output created by 999
+Silence is golden
Signature · 1 line
2.31.1
#6 lore raw
Quoted 71 lines · Darrick J. Wong
Quoted 66 lines · Zorro Lang
Quoted 30 lines · Darrick J. Wong
Quoted 29 lines · Zorro Lang

After soft limits are exceeded, within the grace time, fs quota should allow more space allocation before exceeding hard limits, even if allocating many small files.

This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts when we send warnings"). And will help to expose later behavior changes on this side.

---

According to the review points of:
https://lore.kernel.org/fstests/20220511163806.uc4z7td2remhdru3@zlang-mailbox/T/#m23940b47261165a0442c7ae1eb4d96a1489a2935
V3 did below changes:
1) fix some comments description
2) add a few hard limit test
3) And bring in [PATCH 2/2], to help g/603 to use the common functions of this patch.

Thanks,
Zorro

 common/quota          | 48 +++++++++++++++++++++
 tests/generic/999     | 99 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  2 +
 3 files changed, 149 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out

[snip]

Quoted 5 lines
Quoted 5 lines
tests/generic/999 new file +5 -0
+
+	setquota -${type} $qa_user 1M 200M 0 0 $SCRATCH_MNT
+	setquota -${type} -t 86400 86400 $SCRATCH_MNT
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+	# Exceed the soft quota limit a bit at first
Quoted 8 lines

tests/generic/999 line 69

Quoted 5 lines
tests/generic/999 new file +5 -0
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full 2>&1
+	# Write more data more times under soft quota limit exhausted condition,
+	# but not reach hard limit. To make sure each write won't trigger EDQUOT.
+	for ((i=1; i<=100; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full 2>&1

Hmm -- if pwrite or fsync hit an error, shouldn't we let that end up in 999.out so that the golden output diff fails?

Sure, will remove the "2>&1".

Quoted 15 lines

tests/generic/999 line 81

Quoted 13 lines
tests/generic/999 new file +12 -0
+		if [ $? -ne 0 ];then
+			echo "Unexpected error (type=$type)!"
+			break
+		fi
+	done
+	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+
+	# As we've tested soft limit, now exceed the hard limit and give it a
+	# test in passing.
+	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" >>$seqres.full 2>&1
+	for ((i=1; i<=10; i++));do
+		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" >>$seqres.full 2>&1

Don't we want to encode the actual error in the golden output?

Quoted 3 lines

Hmm... due to I have to filter the ENOSPC or EDQUOT output again for project quota, as I did in generic/603 :-P Or put the that function into common/quota too.

Quoted 5 lines

I think it'd be fine if the golden output contained:

pwrite: Insufficient quota
pwrite: Insufficient quota
pwrite: Not enough space

Sorry I didn't explain that clearly :)

When FSTYP=ext4, it got:
pwrite: Disk quota exceeded
pwrite: Disk quota exceeded
pwrite: Disk quota exceeded
...

When FSTYP=xfs, it got:
SCRATCH_MNT/testfile.hard.1: Disk quota exceeded SCRATCH_MNT/testfile.hard.1: Disk quota exceeded SCRATCH_MNT/t/testfile.hard.1: No space left on device
...

There're 2 differences:
1) ext4 fails on write -- "-c pwrite", but xfs fails on open(O_CREAT) -- "xfs_io -f"
2) For project quota, xfs returns ENOSPC, ext4 returns EDQUOT.

If these're all as expected, I need to filter these differences. And I don't know what other filesystems will print, besides xfs and ext4.

Thanks,
Zorro

Quoted 42 lines

for each of the user/group/project quota tests. Or did I misunderstand?

--D

Quoted 36 lines

Thanks,
Zorro

Quoted 33 lines

--D

Quoted 29 lines
tests/generic/999 new file +18 -0
+		if [ $? -eq 0 ];then
+			echo "Unexpected success (type=$type)!"
+			break
+		fi
+	done
+}
+
+_qmount_option "usrquota"
+exercise u
+_qmount_option "grpquota"
+exercise g
+_qmount_option "prjquota"
+exercise P
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
tests/generic/999.out new file +2 -0
new file mode 100644
index 00000000..3b276ca8
@@ -0,0 +1,2 @@
+QA output created by 999
+Silence is golden
Signature · 1 line
2.31.1