Skip to contentSkip to conversation

quota_remount_test01: update to new API

PATCH New Kory Maincent 2 participants 5 messages Jan 28, 2021 – Feb 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 quota_remount_test01: update to new API

Update to new API
Add test on quota_v2 driver to avoid the above error:
quotaon: Quota format not supported in kernel.

---
 .../fs/quota_remount/quota_remount_test01.sh  | 184 +++++++-----------
 1 file changed, 69 insertions(+), 115 deletions(-)
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +69 -115
index 04b7af922..adcbbe846 100755
@@ -1,126 +1,80 @@
 #!/bin/sh
-################################################################################
-##                                                                            ##
-## Copyright (c) Jan Kara <[email protected]>, 2008                                ##
-## Copyright (c) International Business Machines  Corp., 2009                 ##
-##                                                                            ##
-## 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; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will 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 to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-################################################################################
-#                                                                             ##
-# File :        quota_remount_test01.sh                                       ##
-#                                                                             ##
-# Description:  Test whether kernel properly supports remounting read-only    ##
-#               with quota. This feature was added in kernel 2.6.26. Please   ##
-#               see: http://kernelnewbies.org/Linux_2_6_26, and               ##
-#               http://git.kernel.org/git/?p=linux/kernel/git/torvalds/       ##
-#               linux-2.6.git;a=commit;                                       ##
-#               h=0ff5af8340aa6be44220d7237ef4a654314cf795                    ##
-#               for more info.                                                ##
-#                                                                             ##
-# Author:       Jan Kara <[email protected]>,                                      ##
-#                                                                             ##
-# History:      Sep 18 2008 - Created - Jan Kara <[email protected]>.              ##
-#               Feb 17 2009 - Ported to LTP,                                  ##
-#                             Subrata Modak <[email protected]>      ##
-################################################################################
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) Jan Kara <[email protected]>, 2008
+# Copyright (c) International Business Machines  Corp., 2009
+# Copyright (c) K?ry Maincent <[email protected]> 2020
 
-export TCID=quota_remount_test01
-export TST_TOTAL=1
-export TST_COUNT=0
+TST_NEEDS_CMDS="quotacheck quotaon mkfs.ext3"
+TST_NEEDS_DRIVERS="quota_v2"
+TST_NEEDS_TMPDIR=1
+TST_SETUP=do_setup
+TST_CLEANUP=do_clean
+TST_TESTFUNC=do_test
 
-if [ -z $TMPDIR ]
-then
-	TMPDIR=/tmp
-fi
-MNTDIR=$TMPDIR/mnt
+. tst_test.sh
 
-if tst_kvcmp -lt "2.6.25"; then
-        tst_resm TCONF "Remounting with quotas enabled is not supported!"
-        tst_resm TCONF "You should have kernel 2.6.26 and above running....."
-        exit 32
-fi
-
-if [ ! -d /proc/sys/fs/quota ]; then
-        tst_resm TCONF "Quota not supported in kernel!"
-        exit 0
-fi
-
-if ! command -v quotacheck > /dev/null 2>&1; then
-	tst_resm TCONF "'quotacheck' not found"
-	exit 0
-fi
-
-if ! command -v quotaon > /dev/null 2>&1; then
-	tst_resm TCONF "'quotaon' not found"
-	exit 0
-fi
+do_setup()
+{
+	if tst_kvcmp -lt "2.6.25"; then
+	        tst_res TCONF "Remounting with quotas enabled is not supported!"
+	        tst_brk TCONF "You should have kernel 2.6.26 and above running....."
+	fi
+
+	if [ ! -d /proc/sys/fs/quota ]; then
+	        tst_brk TCONF "Quota not supported in kernel!"
+	        exit 0
+	fi
+	MNTDIR=$TMPDIR/mnt
+	IMAGE=ltp-$$-fs-image
+	dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
+	mkfs.ext3 -q -F -b 4096 $IMAGE
+	mkdir $MNTDIR
+}
 
-die()
+do_clean()
 {
-	echo >&2 $2
 	umount 2>/dev/null $MNTDIR
 	rm 2>/dev/null $IMAGE
-	rmdir 2>/dev/null $MNTDIR
-        tst_resm TFAIL "Quota on Remount Failed"
-	exit $1
 }
 
-cd $TMPDIR || die 2 "Cannot cd to $TMPDIR"
-IMAGE=ltp-$$-fs-image
-dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null || die 2 "Cannot create filesystem image"
-mkfs.ext3 -q -F -b 4096 $IMAGE || die 2 "Could not create the filesystem"
-mkdir $MNTDIR || die 2 "Could not create the mountpoint"
-mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR || die 2 "Could not mount the filesystem"
-tst_resm TINFO "Successfully mounted the File System"
-
-# some distros (CentOS 6.x, for example) doesn't permit creating
-# of quota files in a directory with SELinux file_t type
-if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
-	chcon -t tmp_t $MNTDIR || die 2 "Could not change SELinux file type"
-	tst_resm TINFO "Successfully changed SELinux file type"
-fi
-
-quotacheck -cug $MNTDIR || die 2 "Could not create quota files"
-tst_resm TINFO "Successfully Created Quota Files"
-
-quotaon -ug $MNTDIR || die 2 "Could not turn quota on"
-tst_resm TINFO "Successfully Turned on Quota"
-
-echo "blah" >$MNTDIR/file || die 2 "Could not write to the filesystem"
-tst_resm TINFO "Successfully wrote to the filesystem"
-
-# Get current quota usage
-BLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
-mount -o remount,ro $MNTDIR || die 1 "Could not remount read-only"
-tst_resm TINFO "Successfully Remounted Read-Only FS"
-
-mount -o remount,rw $MNTDIR || die 2 "Could not remount read-write"
-tst_resm TINFO "Successfully Remounted Read-Write FS"
-
-rm $MNTDIR/file
-# Get quota usage after removing the file
-NEWBLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
-# Has quota usage changed properly?
-if [ $BLOCKS -eq $NEWBLOCKS ]; then
-  die 1 "Usage did not change after remount"
-fi
-tst_resm TINFO "Usage successfully Changed after Remount"
-tst_resm TPASS "Quota on Remount Successfull"
+do_test()
+{
+	EXPECT_PASS mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR
+	tst_res TINFO "Successfully mounted the File System"
+
+	# some distros (CentOS 6.x, for example) doesn't permit creating
+	# of quota files in a directory with SELinux file_t type
+	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+		chcon -t tmp_t $MNTDIR || tst_brk TFAIL "Could not change SELinux file type"
+		tst_res TINFO "Successfully changed SELinux file type"
+	fi
+
+	EXPECT_PASS quotacheck -cug $MNTDIR
+	tst_res TINFO "Successfully Created Quota Files"
+
+	EXPECT_PASS quotaon -ug $MNTDIR
+	tst_res TINFO "Successfully Turned on Quota"
+
+	EXPECT_PASS echo "blah" />$MNTDIR/file
+	tst_res TINFO "Successfully wrote to the filesystem"
+
+	# Get current quota usage
+	BLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
+	EXPECT_PASS mount -o remount,ro $MNTDIR
+	tst_res TINFO "Successfully Remounted Read-Only FS"
+
+	EXPECT_PASS mount -o remount,rw $MNTDIR
+	tst_res TINFO "Successfully Remounted Read-Write FS"
+
+	rm $MNTDIR/file
+	# Get quota usage after removing the file
+	NEWBLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
+	# Has quota usage changed properly?
+	if [ $BLOCKS -eq $NEWBLOCKS ]; then
+	   tst_brk TWARN "Usage did not change after remount"
+	fi
+	tst_res TINFO "Usage successfully Changed after Remount"
+	tst_res TPASS "Quota on Remount Successfull"
+}
 
-umount $MNTDIR || die 2 "Could not umount $MNTDIR"
-rmdir $MNTDIR ||  die 2 "Could not remove $MNTDIR"
-rm $IMAGE
-exit 0
+tst_run
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 quota_remount_test01: update to new API

Hi Li, Jan,

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 46

Quoted 2 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +2 -0
+	# some distros (CentOS 6.x, for example) doesn't permit creating
+	# of quota files in a directory with SELinux file_t type

Could you please check if this is still relevant?
If yes, would be enough to detect this case with tst_selinux_enabled (from tst_security.sh)? I.e. considering only SELinux in enforce mode (detecting with /sys/fs/selinux/enforce or /selinux/enforce).

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 50

Quoted 4 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +4 -0
+	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+		chcon -t tmp_t $MNTDIR || tst_brk TFAIL "Could not change SELinux file type"
+		tst_res TINFO "Successfully changed SELinux file type"
+	fi

Kind regards,
Petr

#2 lore raw

PATCH 1/1 quota_remount_test01: update to new API

Hi all,

FYI patch merged with additional cleanup.
Kory, thanks for your work!

Kind regards,
Petr

kernel/fs/quota_remount/quota_remount_test01.sh +41 -41
index adcbbe846..a67e13903 100755
@@ -2,79 +2,79 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) Jan Kara <[email protected]>, 2008
 # Copyright (c) International Business Machines  Corp., 2009
-# Copyright (c) K?ry Maincent <[email protected]> 2020
+# Copyright (c) K?ry Maincent <[email protected]> 2021
+# Copyright (c) 2021 Petr Vorel <[email protected]>
 
-TST_NEEDS_CMDS="quotacheck quotaon mkfs.ext3"
+TST_NEEDS_CMDS="dd mkfs.ext3 mount quota quotacheck quotaon sed tail"
 TST_NEEDS_DRIVERS="quota_v2"
+TST_NEEDS_ROOT=1
 TST_NEEDS_TMPDIR=1
 TST_SETUP=do_setup
 TST_CLEANUP=do_clean
 TST_TESTFUNC=do_test
+TST_MIN_KVER="2.6.26"
 
 . tst_test.sh
 
 do_setup()
 {
-	if tst_kvcmp -lt "2.6.25"; then
-	        tst_res TCONF "Remounting with quotas enabled is not supported!"
-	        tst_brk TCONF "You should have kernel 2.6.26 and above running....."
-	fi
-
 	if [ ! -d /proc/sys/fs/quota ]; then
-	        tst_brk TCONF "Quota not supported in kernel!"
-	        exit 0
+		tst_brk TCONF "quota not supported in kernel"
 	fi
-	MNTDIR=$TMPDIR/mnt
-	IMAGE=ltp-$$-fs-image
-	dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
-	mkfs.ext3 -q -F -b 4096 $IMAGE
+
+	MNTDIR="mnt.$$"
+	IMAGE="ltp-$$-fs-image"
+	ROD dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
+	ROD mkfs.ext3 -q -F -b 4096 $IMAGE
 	mkdir $MNTDIR
 }
 
 do_clean()
 {
-	umount 2>/dev/null $MNTDIR
-	rm 2>/dev/null $IMAGE
+	[ "$mounted" ] || return
+	tst_umount $MNTDIR
+	mounted=
+}
+
+get_blocks()
+{
+	quota -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'
 }
 
 do_test()
 {
-	EXPECT_PASS mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR
-	tst_res TINFO "Successfully mounted the File System"
+	tst_res TINFO "testing quota on remount"
+
+	local blocks newblocks
+
+	ROD mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR
+	mounted=1
 
 	# some distros (CentOS 6.x, for example) doesn't permit creating
 	# of quota files in a directory with SELinux file_t type
-	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
-		chcon -t tmp_t $MNTDIR || tst_brk TFAIL "Could not change SELinux file type"
-		tst_res TINFO "Successfully changed SELinux file type"
+	if tst_selinux_enabled &&
+		tst_cmd_available chcon && ! chcon -t tmp_t $MNTDIR; then
+			tst_brk TCONF "could not change SELinux file type"
 	fi
 
-	EXPECT_PASS quotacheck -cug $MNTDIR
-	tst_res TINFO "Successfully Created Quota Files"
+	ROD quotacheck -cug $MNTDIR
+	ROD quotaon -ug $MNTDIR
+	ROD echo "blah" />$MNTDIR/file
 
-	EXPECT_PASS quotaon -ug $MNTDIR
-	tst_res TINFO "Successfully Turned on Quota"
+	blocks=$(get_blocks)
+	ROD mount -o remount,ro $MNTDIR
+	ROD mount -o remount,rw $MNTDIR
 
-	EXPECT_PASS echo "blah" />$MNTDIR/file
-	tst_res TINFO "Successfully wrote to the filesystem"
+	ROD rm $MNTDIR/file
+	newblocks=$(get_blocks)
 
-	# Get current quota usage
-	BLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
-	EXPECT_PASS mount -o remount,ro $MNTDIR
-	tst_res TINFO "Successfully Remounted Read-Only FS"
+	if [ $blocks -eq $newblocks ]; then
+	   tst_brk TFAIL "usage did not change after remount"
+	fi
 
-	EXPECT_PASS mount -o remount,rw $MNTDIR
-	tst_res TINFO "Successfully Remounted Read-Write FS"
+	tst_res TPASS "quota on remount passed"
 
-	rm $MNTDIR/file
-	# Get quota usage after removing the file
-	NEWBLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
-	# Has quota usage changed properly?
-	if [ $BLOCKS -eq $NEWBLOCKS ]; then
-	   tst_brk TWARN "Usage did not change after remount"
-	fi
-	tst_res TINFO "Usage successfully Changed after Remount"
-	tst_res TPASS "Quota on Remount Successfull"
+	do_clean
 }
 
 tst_run
#3 lore raw

PATCH 1/1 quota_remount_test01: update to new API

In reply to Kory Maincent

Hi Kory,

Quoted 3 lines

Update to new API
Add test on quota_v2 driver to avoid the above error:
quotaon: Quota format not supported in kernel.

+1

...

Quoted 1 line

+TST_NEEDS_CMDS="quotacheck quotaon mkfs.ext3"

TST_NEEDS_CMDS="dd mkfs.ext3 mount quota quotacheck quotaon sed tail" sed and tail are a bit paranoic but it helps to run everywhere.

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 12

Quoted 5 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +5 -0
+TST_NEEDS_DRIVERS="quota_v2"
+TST_NEEDS_TMPDIR=1
+TST_SETUP=do_setup
+TST_CLEANUP=do_clean
+TST_TESTFUNC=do_test

TST_NEEDS_ROOT=1
mount requires root.

...

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 20

Quoted 5 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +5 -0
+do_setup()
+{
+	if tst_kvcmp -lt "2.6.25"; then
+	        tst_res TCONF "Remounting with quotas enabled is not supported!"
+	        tst_brk TCONF "You should have kernel 2.6.26 and above running....."

Please when using TCONF, use it only once (tst_brk TCONF "test require 2.6.26") But new API has TST_MIN_KVER="2.6.26" which is better for this test, tst_kvcmp is needed for some special cases (skipping only single test etc).

Quoted 7 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +7 -0
+	fi
+
+	if [ ! -d /proc/sys/fs/quota ]; then
+	        tst_brk TCONF "Quota not supported in kernel!"
+	        exit 0
+	fi
+	MNTDIR=$TMPDIR/mnt

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 37

Quoted 10 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +6 -0
+	IMAGE=ltp-$$-fs-image
+	dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
+	mkfs.ext3 -q -F -b 4096 $IMAGE
+	mkdir $MNTDIR
+}
 
+do_clean()
 {
 	umount 2>/dev/null $MNTDIR
 	rm 2>/dev/null $IMAGE

Cleanup should use tst_umount, removing file is not necessary. And there should be guarded with flag to try umount only when mounted:

do_clean()

{
	[ "$mounted" ] || return
	tst_umount $MNTDIR
}

And in do_test():

ROD mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR mounted=1

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 43

Quoted 4 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +4 -0
+do_test()
+{
+	EXPECT_PASS mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR
+	tst_res TINFO "Successfully mounted the File System"

Here I'd use just ROD instead of EXPECT_PASS. ROD is used on preparation commands, on failure ($? -ne 0) prints the command and quit testing, which is required here (there is no point to continue if mount fails. If this were subject of testing EXPECT_PASS_BRK could be used (EXPECT_PASS just TFAIL, but continue testing).

But I'd use ROD for most of the commands, IMHO only $BLOCKS -eq $NEWBLOCKS check is the test case. Or am I wrong?

tst_res TINFO messages are definitely useless (regardless whether ROD or EXPECT_PASS* is used) + we don't use that camel case.

NOTE mount is here and not in setup to allow running test more than once with -iN (N is a positive number).

ROD mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR mounted=1

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 48

Quoted 5 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +5 -0
+
+	# some distros (CentOS 6.x, for example) doesn't permit creating
+	# of quota files in a directory with SELinux file_t type
+	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+		chcon -t tmp_t $MNTDIR || tst_brk TFAIL "Could not change SELinux file type"

Not sure if "Could not change SELinux file type" is bug or configuration issue. I'd personally consider it as config issue and use TCONF here. But maybe I'm wrong.

Quoted 16 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +16 -0
+		tst_res TINFO "Successfully changed SELinux file type"
+	fi
+
+	EXPECT_PASS quotacheck -cug $MNTDIR
+	tst_res TINFO "Successfully Created Quota Files"
+
+	EXPECT_PASS quotaon -ug $MNTDIR
+	tst_res TINFO "Successfully Turned on Quota"
+
+	EXPECT_PASS echo "blah" />$MNTDIR/file
+	tst_res TINFO "Successfully wrote to the filesystem"
+
+	# Get current quota usage
+	BLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
+	EXPECT_PASS mount -o remount,ro $MNTDIR
+	tst_res TINFO "Successfully Remounted Read-Only FS"

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 74

Quoted 10 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +10 -0
+
+	EXPECT_PASS mount -o remount,rw $MNTDIR
+	tst_res TINFO "Successfully Remounted Read-Write FS"
+
+	rm $MNTDIR/file
+	# Get quota usage after removing the file
+	NEWBLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
+	# Has quota usage changed properly?
+	if [ $BLOCKS -eq $NEWBLOCKS ]; then
+	   tst_brk TWARN "Usage did not change after remount"

I consider this as an error.

On one of my VM I see
Error relocating /usr/bin/quota: reallocarray: symbol not found quota_remount_test01 1 TWARN: usage did not change after remount => obviously quota needs some fix here :).

testcases/kernel/fs/quota_remount/quota_remount_test01.sh line 78

Quoted 4 lines
testcases/kernel/fs/quota_remount/quota_remount_test01.sh +4 -0
+	fi
+	tst_res TINFO "Usage successfully Changed after Remount"
+	tst_res TPASS "Quota on Remount Successfull"
+}

...

I suggest to merge this (adapting test for more runs, using ROD, adding get_blocks(), ...).
Just waiting Jan and Li for info about SELinux.

Kind regards,
Petr

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) Jan Kara <[email protected]>, 2008
# Copyright (c) International Business Machines Corp., 2009 # Copyright (c) K?ry Maincent <[email protected]> 2021 # Copyright (c) 2021 Petr Vorel <[email protected]>

TST_NEEDS_CMDS="dd mkfs.ext3 mount quota quotacheck quotaon sed tail" TST_NEEDS_DRIVERS="quota_v2"
TST_NEEDS_ROOT=1
TST_NEEDS_TMPDIR=1
TST_SETUP=do_setup
TST_CLEANUP=do_clean
TST_TESTFUNC=do_test
TST_MIN_KVER="2.6.26"

. tst_test.sh

do_setup()

{
	if [ ! -d /proc/sys/fs/quota ]; then
		tst_brk TCONF "quota not supported in kernel"
	fi

	MNTDIR="mnt.$$"
	IMAGE="ltp-$$-fs-image"
	ROD dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
	ROD mkfs.ext3 -q -F -b 4096 $IMAGE
	mkdir $MNTDIR
}

do_clean()

{
	[ "$mounted" ] || return
	tst_umount $MNTDIR
	mounted=
}

get_blocks()

{
	quota -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'
}

do_test()
{
tst_res TINFO "testing quota on remount"

local blocks newblocks

ROD mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR mounted=1

# some distros (CentOS 6.x, for example) doesn't permit creating # of quota files in a directory with SELinux file_t type if tst_selinux_enabled &&
tst_cmd_available chcon && ! chcon -t tmp_t $MNTDIR; then
tst_brk TCONF "could not change SELinux file type"
fi

ROD quotacheck -cug $MNTDIR
ROD quotaon -ug $MNTDIR
ROD echo "blah" />$MNTDIR/file

blocks=$(get_blocks)
ROD mount -o remount,ro $MNTDIR
ROD mount -o remount,rw $MNTDIR

ROD rm $MNTDIR/file
newblocks=$(get_blocks)

if [ $blocks -eq $newblocks ]; then
tst_brk TFAIL "usage did not change after remount"
fi

tst_res TPASS "quota on remount passed"

do_clean
}

tst_run

#4 lore raw

PATCH 1/1 quota_remount_test01: update to new API

Hi Petr,

Quoted 7 lines · On Fri, 29 Jan 2021 16:22:33 +0100 Petr Vorel <[email protected]> wrote:

Hi Kory,

Quoted 3 lines

Update to new API
Add test on quota_v2 driver to avoid the above error:
quotaon: Quota format not supported in kernel.

+1

Thanks for the review and all the explanation.
The new test looks better.

Regards,

K?ry