Skip to contentSkip to conversation

generic: use _qmount_option and _qmount

PATCH Superseded Su Yue 4 participants 6 messages Nov 24, 2025 – Dec 3, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Su Yue

author
#0 lore raw

PATCH 1/1 generic: use _qmount_option and _qmount

Many generic tests call _scratch_mount -o usrquota then chmod 777, quotacheck and quotaon.
It can be simpilfied to _qmount_option and _qmount. The later function already calls quotacheck, quota and chmod.

Convertaions can save a few lines. tests/generic/380 is an exception because it tests chown.

---
 tests/generic/082 |  9 ++-------
 tests/generic/219 | 11 ++++-------
 tests/generic/230 | 11 ++++++-----
 tests/generic/231 |  6 ++----
 tests/generic/232 |  6 ++----
 tests/generic/233 |  6 ++----
 tests/generic/234 |  5 ++---
 tests/generic/235 |  5 ++---
 tests/generic/244 |  1 -
 tests/generic/270 |  6 ++----
 tests/generic/280 |  5 ++---
 tests/generic/400 |  2 +-
 12 files changed, 27 insertions(+), 46 deletions(-)
tests/generic/082 +2 -7
index f078ef2ffff9..6bb9cf2a22ae 100755
@@ -23,13 +23,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-
-# xfs doesn't need these setups and quotacheck even fails on xfs, so just
-# redirect the output to $seqres.full for debug purpose and ignore the results,
-# as we check the quota status later anyway.
-quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
-quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+_qmount_option 'usrquota,grpquota'
+_qmount "usrquota,grpquota"
 
 # first remount ro with a bad option, a failed remount ro should not disable
 # quota, but currently xfs doesn't fail in this case, the unknown option is
tests/generic/219 +4 -7
index 642823859886..a2eb0b20f408 100755
@@ -91,25 +91,22 @@ test_accounting()
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
 
 echo; echo "### test user accounting"
-export MOUNT_OPTIONS="-o usrquota"
+_qmount_option "usrquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=u
 test_files
 test_accounting
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group accounting"
-export MOUNT_OPTIONS="-o grpquota"
+_qmount_option "grpquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=g
 test_files
 test_accounting
tests/generic/230 +6 -5
index a8caf5a808c3..0a680dbc874b 100755
@@ -99,7 +99,8 @@ grace=2
 _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
@@ -113,8 +114,8 @@ setquota -g -t $grace $grace $SCRATCH_MNT
 _scratch_unmount
 
 echo; echo "### test user limit enforcement"
-_scratch_mount "-o usrquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota"
+_qmount
 type=u
 test_files
 test_enforcement
@@ -122,8 +123,8 @@ cleanup_files
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group limit enforcement"
-_scratch_mount "-o grpquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "grpquota"
+_qmount
 type=g
 test_files
 test_enforcement
tests/generic/231 +2 -4
index ce7e62ea1886..02910523d0b5 100755
@@ -47,10 +47,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _fsx 1; then
 	_scratch_unmount 2>/dev/null
tests/generic/232 +2 -4
index c903a5619045..21375809d299 100755
@@ -44,10 +44,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 _fsstress
 _check_quota_usage
tests/generic/233 +2 -4
index 3fc1b63abb24..4606f3bde2ab 100755
@@ -59,10 +59,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 2>/dev/null
 
 _fsstress
tests/generic/234 +2 -3
index 4b25fc6507cc..2c596492a3e0 100755
@@ -66,9 +66,8 @@ _require_quota
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon -u -g $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 test_setting
 _scratch_unmount
 
tests/generic/235 +2 -3
index 037c29e806db..7a616650fc8f 100755
@@ -25,9 +25,8 @@ do_repquota()
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 
 touch $SCRATCH_MNT/testfile
 chown $qa_user:$qa_user $SCRATCH_MNT/testfile
tests/generic/244 +0 -1
index b68035129c82..989bb4f5385e 100755
@@ -66,7 +66,6 @@ done
 # remount just for kicks, make sure we get it off disk
 _scratch_unmount
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 
 # Read them back by iterating based on quotas returned.
 # This should match what we set, even if we don't directly
tests/generic/270 +2 -4
index c3d5127a0b51..9ac829a7379f 100755
@@ -62,10 +62,8 @@ _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _workout; then
 	_scratch_unmount 2>/dev/null
tests/generic/280 +2 -3
index 3108fd23fb70..fae0a02145cf 100755
@@ -34,9 +34,8 @@ _require_freeze
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 xfs_freeze -f $SCRATCH_MNT
 setquota -u root 1 2 3 4 $SCRATCH_MNT &
 pid=$!
tests/generic/400 +1 -1
index 77970da69a41..ef27c254167c 100755
@@ -22,7 +22,7 @@ _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
 
-MOUNT_OPTIONS="-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
 _qmount
 _require_getnextquota
 
Signature · 1 line
2.48.1
#1 lore raw
Quoted 2 lines · Su Yue

Many generic tests call _scratch_mount -o usrquota then chmod 777, quotacheck and quotaon.

What does the chmod 777 do, in relation to the quota{check,on} programs? Is it necessary for the root dir to be world writable (and executable!) for quota tools to work?

Quoted 4 lines

It can be simpilfied to _qmount_option and _qmount. The later function already calls quotacheck, quota and chmod.

Convertaions can save a few lines. tests/generic/380 is an exception

"Conversions" ?

--D

Quoted 253 lines

because it tests chown.

---
 tests/generic/082 |  9 ++-------
 tests/generic/219 | 11 ++++-------
 tests/generic/230 | 11 ++++++-----
 tests/generic/231 |  6 ++----
 tests/generic/232 |  6 ++----
 tests/generic/233 |  6 ++----
 tests/generic/234 |  5 ++---
 tests/generic/235 |  5 ++---
 tests/generic/244 |  1 -
 tests/generic/270 |  6 ++----
 tests/generic/280 |  5 ++---
 tests/generic/400 |  2 +-
 12 files changed, 27 insertions(+), 46 deletions(-)
tests/generic/082 +2 -7
index f078ef2ffff9..6bb9cf2a22ae 100755
@@ -23,13 +23,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-
-# xfs doesn't need these setups and quotacheck even fails on xfs, so just
-# redirect the output to $seqres.full for debug purpose and ignore the results,
-# as we check the quota status later anyway.
-quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
-quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+_qmount_option 'usrquota,grpquota'
+_qmount "usrquota,grpquota"
 
 # first remount ro with a bad option, a failed remount ro should not disable
 # quota, but currently xfs doesn't fail in this case, the unknown option is
tests/generic/219 +4 -7
index 642823859886..a2eb0b20f408 100755
@@ -91,25 +91,22 @@ test_accounting()
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
 
 echo; echo "### test user accounting"
-export MOUNT_OPTIONS="-o usrquota"
+_qmount_option "usrquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=u
 test_files
 test_accounting
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group accounting"
-export MOUNT_OPTIONS="-o grpquota"
+_qmount_option "grpquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=g
 test_files
 test_accounting
tests/generic/230 +6 -5
index a8caf5a808c3..0a680dbc874b 100755
@@ -99,7 +99,8 @@ grace=2
 _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
@@ -113,8 +114,8 @@ setquota -g -t $grace $grace $SCRATCH_MNT
 _scratch_unmount
 
 echo; echo "### test user limit enforcement"
-_scratch_mount "-o usrquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota"
+_qmount
 type=u
 test_files
 test_enforcement
@@ -122,8 +123,8 @@ cleanup_files
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group limit enforcement"
-_scratch_mount "-o grpquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "grpquota"
+_qmount
 type=g
 test_files
 test_enforcement
tests/generic/231 +2 -4
index ce7e62ea1886..02910523d0b5 100755
@@ -47,10 +47,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _fsx 1; then
 	_scratch_unmount 2>/dev/null
tests/generic/232 +2 -4
index c903a5619045..21375809d299 100755
@@ -44,10 +44,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 _fsstress
 _check_quota_usage
tests/generic/233 +2 -4
index 3fc1b63abb24..4606f3bde2ab 100755
@@ -59,10 +59,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 2>/dev/null
 
 _fsstress
tests/generic/234 +2 -3
index 4b25fc6507cc..2c596492a3e0 100755
@@ -66,9 +66,8 @@ _require_quota
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon -u -g $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 test_setting
 _scratch_unmount
 
tests/generic/235 +2 -3
index 037c29e806db..7a616650fc8f 100755
@@ -25,9 +25,8 @@ do_repquota()
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 
 touch $SCRATCH_MNT/testfile
 chown $qa_user:$qa_user $SCRATCH_MNT/testfile
tests/generic/244 +0 -1
index b68035129c82..989bb4f5385e 100755
@@ -66,7 +66,6 @@ done
 # remount just for kicks, make sure we get it off disk
 _scratch_unmount
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 
 # Read them back by iterating based on quotas returned.
 # This should match what we set, even if we don't directly
tests/generic/270 +2 -4
index c3d5127a0b51..9ac829a7379f 100755
@@ -62,10 +62,8 @@ _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _workout; then
 	_scratch_unmount 2>/dev/null
tests/generic/280 +2 -3
index 3108fd23fb70..fae0a02145cf 100755
@@ -34,9 +34,8 @@ _require_freeze
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 xfs_freeze -f $SCRATCH_MNT
 setquota -u root 1 2 3 4 $SCRATCH_MNT &
 pid=$!
tests/generic/400 +1 -1
index 77970da69a41..ef27c254167c 100755
@@ -22,7 +22,7 @@ _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
 
-MOUNT_OPTIONS="-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
 _qmount
 _require_getnextquota
 
Signature · 1 line
2.48.1
#2 lore raw
Quoted 7 lines · Darrick J. Wong
Quoted 2 lines · Su Yue

Many generic tests call _scratch_mount -o usrquota then chmod 777, quotacheck and quotaon.

What does the chmod 777 do, in relation to the quota{check,on} programs? Is it necessary for the root dir to be world writable (and executable!) for quota tools to work?

Hi Darrick,

The _qmount always does "chmod ugo+rwx $SCRATCH_MNT", I think it's for regular users (e.g. fsgqa) can write into $SCRATCH_MNT. If a test case doesn't use regular user, the "chmod 777" isn't necessary. The author of _qmount might think "chmod 777 $SCRATCH_MN" doesn't hurt anything quota test, so always does that no matter if it's needed. If you think it hurts something, we can only do that for the cases who really need that :)

I think this patch trys to help quota test cases to use unified common helpers, most of them don't need the "chmod 777" actually, right Su?

Thanks,
Zorro

Quoted 264 lines
Quoted 5 lines

It can be simpilfied to _qmount_option and _qmount. The later function already calls quotacheck, quota and chmod.

Convertaions can save a few lines. tests/generic/380 is an exception

"Conversions" ?

--D

Quoted 253 lines

because it tests chown.

---
 tests/generic/082 |  9 ++-------
 tests/generic/219 | 11 ++++-------
 tests/generic/230 | 11 ++++++-----
 tests/generic/231 |  6 ++----
 tests/generic/232 |  6 ++----
 tests/generic/233 |  6 ++----
 tests/generic/234 |  5 ++---
 tests/generic/235 |  5 ++---
 tests/generic/244 |  1 -
 tests/generic/270 |  6 ++----
 tests/generic/280 |  5 ++---
 tests/generic/400 |  2 +-
 12 files changed, 27 insertions(+), 46 deletions(-)
tests/generic/082 +2 -7
index f078ef2ffff9..6bb9cf2a22ae 100755
@@ -23,13 +23,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-
-# xfs doesn't need these setups and quotacheck even fails on xfs, so just
-# redirect the output to $seqres.full for debug purpose and ignore the results,
-# as we check the quota status later anyway.
-quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
-quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+_qmount_option 'usrquota,grpquota'
+_qmount "usrquota,grpquota"
 
 # first remount ro with a bad option, a failed remount ro should not disable
 # quota, but currently xfs doesn't fail in this case, the unknown option is
tests/generic/219 +4 -7
index 642823859886..a2eb0b20f408 100755
@@ -91,25 +91,22 @@ test_accounting()
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
 
 echo; echo "### test user accounting"
-export MOUNT_OPTIONS="-o usrquota"
+_qmount_option "usrquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=u
 test_files
 test_accounting
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group accounting"
-export MOUNT_OPTIONS="-o grpquota"
+_qmount_option "grpquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=g
 test_files
 test_accounting
tests/generic/230 +6 -5
index a8caf5a808c3..0a680dbc874b 100755
@@ -99,7 +99,8 @@ grace=2
 _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
@@ -113,8 +114,8 @@ setquota -g -t $grace $grace $SCRATCH_MNT
 _scratch_unmount
 
 echo; echo "### test user limit enforcement"
-_scratch_mount "-o usrquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota"
+_qmount
 type=u
 test_files
 test_enforcement
@@ -122,8 +123,8 @@ cleanup_files
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group limit enforcement"
-_scratch_mount "-o grpquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "grpquota"
+_qmount
 type=g
 test_files
 test_enforcement
tests/generic/231 +2 -4
index ce7e62ea1886..02910523d0b5 100755
@@ -47,10 +47,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _fsx 1; then
 	_scratch_unmount 2>/dev/null
tests/generic/232 +2 -4
index c903a5619045..21375809d299 100755
@@ -44,10 +44,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 _fsstress
 _check_quota_usage
tests/generic/233 +2 -4
index 3fc1b63abb24..4606f3bde2ab 100755
@@ -59,10 +59,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 2>/dev/null
 
 _fsstress
tests/generic/234 +2 -3
index 4b25fc6507cc..2c596492a3e0 100755
@@ -66,9 +66,8 @@ _require_quota
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon -u -g $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 test_setting
 _scratch_unmount
 
tests/generic/235 +2 -3
index 037c29e806db..7a616650fc8f 100755
@@ -25,9 +25,8 @@ do_repquota()
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 
 touch $SCRATCH_MNT/testfile
 chown $qa_user:$qa_user $SCRATCH_MNT/testfile
tests/generic/244 +0 -1
index b68035129c82..989bb4f5385e 100755
@@ -66,7 +66,6 @@ done
 # remount just for kicks, make sure we get it off disk
 _scratch_unmount
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 
 # Read them back by iterating based on quotas returned.
 # This should match what we set, even if we don't directly
tests/generic/270 +2 -4
index c3d5127a0b51..9ac829a7379f 100755
@@ -62,10 +62,8 @@ _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _workout; then
 	_scratch_unmount 2>/dev/null
tests/generic/280 +2 -3
index 3108fd23fb70..fae0a02145cf 100755
@@ -34,9 +34,8 @@ _require_freeze
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 xfs_freeze -f $SCRATCH_MNT
 setquota -u root 1 2 3 4 $SCRATCH_MNT &
 pid=$!
tests/generic/400 +1 -1
index 77970da69a41..ef27c254167c 100755
@@ -22,7 +22,7 @@ _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
 
-MOUNT_OPTIONS="-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
 _qmount
 _require_getnextquota
 
Signature · 1 line
2.48.1
#3 lore raw
Quoted 9 lines · Zorro Lang
Quoted 7 lines · Darrick J. Wong
Quoted 2 lines · Su Yue

Many generic tests call _scratch_mount -o usrquota then chmod 777, quotacheck and quotaon.

What does the chmod 777 do, in relation to the quota{check,on} programs? Is it necessary for the root dir to be world writable (and executable!) for quota tools to work?

Quoted 8 lines

Hi Darrick,

The _qmount always does "chmod ugo+rwx $SCRATCH_MNT", I think it's for regular users (e.g. fsgqa) can write into $SCRATCH_MNT. If a test case doesn't use regular user, the "chmod 777" isn't necessary. The author of _qmount might think "chmod 777 $SCRATCH_MN" doesn't hurt anything quota test, so always does that no matter if it's needed.

I guess so. The code cames from 2001.

Quoted 3 lines

If you think it hurts something, we can only do that for the cases who really need that :)

Yeah. We can remove the "chmod 777 $SCRATCH_MNT" from _qmount and adjust caeses influenced.

Quoted 3 lines

I think this patch trys to help quota test cases to use unified common helpers, most of them don't need the "chmod 777" actually, right Su?

Correct. To be more accurate, 4 cases need "chmod 777".

--
Su

Quoted 274 lines

Thanks,
Zorro

Quoted 270 lines
Quoted 5 lines

It can be simpilfied to _qmount_option and _qmount. The later function already calls quotacheck, quota and chmod.

Convertaions can save a few lines. tests/generic/380 is an exception

"Conversions" ?

--D

Quoted 259 lines

because it tests chown.

---
 tests/generic/082 |  9 ++-------
 tests/generic/219 | 11 ++++-------
 tests/generic/230 | 11 ++++++-----
 tests/generic/231 |  6 ++----
 tests/generic/232 |  6 ++----
 tests/generic/233 |  6 ++----
 tests/generic/234 |  5 ++---
 tests/generic/235 |  5 ++---
 tests/generic/244 |  1 -
 tests/generic/270 |  6 ++----
 tests/generic/280 |  5 ++---
 tests/generic/400 |  2 +-
 12 files changed, 27 insertions(+), 46 deletions(-)
tests/generic/082 +0 -3
index f078ef2ffff9..6bb9cf2a22ae 100755
@@ -23,13 +23,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-
-# xfs doesn't need these setups and quotacheck even fails on 

xfs, so just
-# redirect the output to $seqres.full for debug purpose and ignore the results,

tests/generic/082 +2 -3
-# as we check the quota status later anyway.
-quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
-quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+_qmount_option 'usrquota,grpquota'
+_qmount "usrquota,grpquota"
 
 # first remount ro with a bad option, a failed remount ro 
 should not disable
 # quota, but currently xfs doesn't fail in this case, the 
 unknown option is
tests/generic/219 +4 -7
index 642823859886..a2eb0b20f408 100755
@@ -91,25 +91,22 @@ test_accounting()
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
 
 echo; echo "### test user accounting"
-export MOUNT_OPTIONS="-o usrquota"
+_qmount_option "usrquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=u
 test_files
 test_accounting
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group accounting"
-export MOUNT_OPTIONS="-o grpquota"
+_qmount_option "grpquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=g
 test_files
 test_accounting
tests/generic/230 +6 -5
index a8caf5a808c3..0a680dbc874b 100755
@@ -99,7 +99,8 @@ grace=2
 _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
@@ -113,8 +114,8 @@ setquota -g -t $grace $grace $SCRATCH_MNT
 _scratch_unmount
 
 echo; echo "### test user limit enforcement"
-_scratch_mount "-o usrquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota"
+_qmount
 type=u
 test_files
 test_enforcement
@@ -122,8 +123,8 @@ cleanup_files
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group limit enforcement"
-_scratch_mount "-o grpquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "grpquota"
+_qmount
 type=g
 test_files
 test_enforcement
tests/generic/231 +2 -4
index ce7e62ea1886..02910523d0b5 100755
@@ -47,10 +47,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _fsx 1; then
 	_scratch_unmount 2>/dev/null
tests/generic/232 +2 -4
index c903a5619045..21375809d299 100755
@@ -44,10 +44,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 _fsstress
 _check_quota_usage
tests/generic/233 +2 -4
index 3fc1b63abb24..4606f3bde2ab 100755
@@ -59,10 +59,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 
 2>/dev/null
 

_fsstress

tests/generic/234 +2 -3
index 4b25fc6507cc..2c596492a3e0 100755
@@ -66,9 +66,8 @@ _require_quota
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon -u -g $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 test_setting
 _scratch_unmount
 
tests/generic/235 +2 -3
index 037c29e806db..7a616650fc8f 100755
@@ -25,9 +25,8 @@ do_repquota()
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 
 touch $SCRATCH_MNT/testfile
 chown $qa_user:$qa_user $SCRATCH_MNT/testfile
tests/generic/244 +0 -1
index b68035129c82..989bb4f5385e 100755
@@ -66,7 +66,6 @@ done
 # remount just for kicks, make sure we get it off disk
 _scratch_unmount
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 
 # Read them back by iterating based on quotas returned.
 # This should match what we set, even if we don't directly
tests/generic/270 +2 -4
index c3d5127a0b51..9ac829a7379f 100755
@@ -62,10 +62,8 @@ _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _workout; then
tests/generic/270 +0 -0
 	_scratch_unmount 2>/dev/null
tests/generic/280 +2 -3
index 3108fd23fb70..fae0a02145cf 100755
@@ -34,9 +34,8 @@ _require_freeze
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 xfs_freeze -f $SCRATCH_MNT
 setquota -u root 1 2 3 4 $SCRATCH_MNT &
 pid=$!
tests/generic/400 +1 -2
index 77970da69a41..ef27c254167c 100755
@@ -22,7 +22,7 @@ _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
 
-MOUNT_OPTIONS="-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
 _qmount
 _require_getnextquota
 
--

2.48.1

#4 lore raw
Quoted 34 lines · Su Yue
Quoted 13 lines · Zorro Lang
Quoted 9 lines · Darrick J. Wong
Quoted 2 lines · Su Yue

Many generic tests call _scratch_mount -o usrquota then chmod 777, quotacheck and quotaon.

What does the chmod 777 do, in relation to the quota{check,on} programs?
Is it necessary for the root dir to be world writable (and executable!)
for quota tools to work?

Hi Darrick,

Quoted 10 lines

The _qmount always does "chmod ugo+rwx $SCRATCH_MNT", I think it's for regular
users (e.g. fsgqa) can write into $SCRATCH_MNT. If a test case doesn't use
regular user, the "chmod 777" isn't necessary. The author of _qmount might
think "chmod 777 $SCRATCH_MN" doesn't hurt anything quota test, so always
does that no matter if it's needed.

I guess so. The code cames from 2001.

Quoted 3 lines

If you think it hurts something, we can only do that for the cases who really need that :)

Yeah. We can remove the "chmod 777 $SCRATCH_MNT" from _qmount and adjust caeses influenced.

Quoted 6 lines
Quoted 4 lines

I think this patch trys to help quota test cases to use unified common helpers,
most of them don't need the "chmod 777" actually, right Su?

Correct. To be more accurate, 4 cases need "chmod 777".

Ok, yeah, let's only call chmod 0777 for the tests that need it.

--D

Quoted 279 lines

--
Su

Quoted 275 lines

Thanks,
Zorro

Quoted 271 lines
Quoted 5 lines

It can be simpilfied to _qmount_option and _qmount. The later function already calls quotacheck, quota and chmod.

Convertaions can save a few lines. tests/generic/380 is an >

exception

"Conversions" ?

--D

Quoted 23 lines

because it tests chown.

---
 tests/generic/082 |  9 ++-------
 tests/generic/219 | 11 ++++-------
 tests/generic/230 | 11 ++++++-----
 tests/generic/231 |  6 ++----
 tests/generic/232 |  6 ++----
 tests/generic/233 |  6 ++----
 tests/generic/234 |  5 ++---
 tests/generic/235 |  5 ++---
 tests/generic/244 |  1 -
 tests/generic/270 |  6 ++----
 tests/generic/280 |  5 ++---
 tests/generic/400 |  2 +-
 12 files changed, 27 insertions(+), 46 deletions(-)
tests/generic/082 +0 -0
index f078ef2ffff9..6bb9cf2a22ae 100755

tests/generic/082 _require_scratch · line 28

Quoted 6 lines
tests/generic/082 +0 -3
@@ -23,13 +23,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-
-# xfs doesn't need these setups and quotacheck even fails on >

xfs, so just

tests/generic/082 _require_scratch · line 29

Quoted 1 line
tests/generic/082 +0 -1
-# redirect the output to $seqres.full for debug purpose and >

ignore the results,

tests/generic/082 _require_scratch

Quoted 7 lines
tests/generic/082 +2 -3
-# as we check the quota status later anyway.
-quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
-quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+_qmount_option 'usrquota,grpquota'
+_qmount "usrquota,grpquota"
 
 # first remount ro with a bad option, a failed remount ro >

should not disable

tests/generic/082 _require_scratch · line 30

Quoted 1 line
tests/generic/082 +0 -0
 # quota, but currently xfs doesn't fail in this case, the >

unknown option is

Quoted 109 lines
tests/generic/219 +4 -7
index 642823859886..a2eb0b20f408 100755
@@ -91,25 +91,22 @@ test_accounting()
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
 
 echo; echo "### test user accounting"
-export MOUNT_OPTIONS="-o usrquota"
+_qmount_option "usrquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=u
 test_files
 test_accounting
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group accounting"
-export MOUNT_OPTIONS="-o grpquota"
+_qmount_option "grpquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=g
 test_files
 test_accounting
tests/generic/230 +6 -5
index a8caf5a808c3..0a680dbc874b 100755
@@ -99,7 +99,8 @@ grace=2
 _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
@@ -113,8 +114,8 @@ setquota -g -t $grace $grace $SCRATCH_MNT
 _scratch_unmount
 
 echo; echo "### test user limit enforcement"
-_scratch_mount "-o usrquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota"
+_qmount
 type=u
 test_files
 test_enforcement
@@ -122,8 +123,8 @@ cleanup_files
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group limit enforcement"
-_scratch_mount "-o grpquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "grpquota"
+_qmount
 type=g
 test_files
 test_enforcement
tests/generic/231 +2 -4
index ce7e62ea1886..02910523d0b5 100755
@@ -47,10 +47,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _fsx 1; then
 	_scratch_unmount 2>/dev/null
tests/generic/232 +2 -4
index c903a5619045..21375809d299 100755
@@ -44,10 +44,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 _fsstress
 _check_quota_usage
tests/generic/233 +0 -0
index 3fc1b63abb24..4606f3bde2ab 100755

tests/generic/233 _require_quota · line 64

Quoted 10 lines
tests/generic/233 +2 -4
@@ -59,10 +59,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT >

2>/dev/null

Quoted 51 lines
tests/generic/233 +0 -0
 _fsstress
tests/generic/234 +2 -3
index 4b25fc6507cc..2c596492a3e0 100755
@@ -66,9 +66,8 @@ _require_quota
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon -u -g $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 test_setting
 _scratch_unmount
 
tests/generic/235 +2 -3
index 037c29e806db..7a616650fc8f 100755
@@ -25,9 +25,8 @@ do_repquota()
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 
 touch $SCRATCH_MNT/testfile
 chown $qa_user:$qa_user $SCRATCH_MNT/testfile
tests/generic/244 +0 -1
index b68035129c82..989bb4f5385e 100755
@@ -66,7 +66,6 @@ done
 # remount just for kicks, make sure we get it off disk
 _scratch_unmount
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 
 # Read them back by iterating based on quotas returned.
 # This should match what we set, even if we don't directly
tests/generic/270 +0 -0
index c3d5127a0b51..9ac829a7379f 100755

tests/generic/270 _require_command "$SETCAP_PROG" setcap · line 64

Quoted 3 lines
tests/generic/270 +0 -0
@@ -62,10 +62,8 @@ _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full >

2>&1

Quoted 42 lines
tests/generic/270 +2 -4
-_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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _workout; then
 	_scratch_unmount 2>/dev/null
tests/generic/280 +2 -3
index 3108fd23fb70..fae0a02145cf 100755
@@ -34,9 +34,8 @@ _require_freeze
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 xfs_freeze -f $SCRATCH_MNT
 setquota -u root 1 2 3 4 $SCRATCH_MNT &
 pid=$!
tests/generic/400 +1 -2
index 77970da69a41..ef27c254167c 100755
@@ -22,7 +22,7 @@ _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
 
-MOUNT_OPTIONS="-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
 _qmount
 _require_getnextquota
 
--

2.48.1

#5 lore raw
In reply to Darrick J. Wong
Quoted 8 lines · Darrick J. Wong
Quoted 2 lines · Su Yue

Many generic tests call _scratch_mount -o usrquota then chmod 777, quotacheck and quotaon.

What does the chmod 777 do, in relation to the quota{check,on} programs? Is it necessary for the root dir to be world writable (and executable!) for quota tools to work?

It's unnecessary. Only tests calling _su $qa_user or _file_as_id need the permisson.

Quoted 7 lines
Quoted 4 lines

It can be simpilfied to _qmount_option and _qmount. The later function already calls quotacheck, quota and chmod.

Convertaions can save a few lines. tests/generic/380 is an exception

"Conversions" ?

Yeah...

--
Su

Quoted 261 lines

--D

Quoted 259 lines

because it tests chown.

---
 tests/generic/082 |  9 ++-------
 tests/generic/219 | 11 ++++-------
 tests/generic/230 | 11 ++++++-----
 tests/generic/231 |  6 ++----
 tests/generic/232 |  6 ++----
 tests/generic/233 |  6 ++----
 tests/generic/234 |  5 ++---
 tests/generic/235 |  5 ++---
 tests/generic/244 |  1 -
 tests/generic/270 |  6 ++----
 tests/generic/280 |  5 ++---
 tests/generic/400 |  2 +-
 12 files changed, 27 insertions(+), 46 deletions(-)
tests/generic/082 +0 -3
index f078ef2ffff9..6bb9cf2a22ae 100755
@@ -23,13 +23,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-
-# xfs doesn't need these setups and quotacheck even fails on 

xfs, so just
-# redirect the output to $seqres.full for debug purpose and ignore the results,

tests/generic/082 +2 -3
-# as we check the quota status later anyway.
-quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
-quotaon $SCRATCH_MNT >>$seqres.full 2>&1
+_qmount_option 'usrquota,grpquota'
+_qmount "usrquota,grpquota"
 
 # first remount ro with a bad option, a failed remount ro 
 should not disable
 # quota, but currently xfs doesn't fail in this case, the 
 unknown option is
tests/generic/219 +4 -7
index 642823859886..a2eb0b20f408 100755
@@ -91,25 +91,22 @@ test_accounting()
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
 
 echo; echo "### test user accounting"
-export MOUNT_OPTIONS="-o usrquota"
+_qmount_option "usrquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=u
 test_files
 test_accounting
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group accounting"
-export MOUNT_OPTIONS="-o grpquota"
+_qmount_option "grpquota"
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 type=g
 test_files
 test_accounting
tests/generic/230 +6 -5
index a8caf5a808c3..0a680dbc874b 100755
@@ -99,7 +99,8 @@ grace=2
 _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
+_qmount
 _force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
@@ -113,8 +114,8 @@ setquota -g -t $grace $grace $SCRATCH_MNT
 _scratch_unmount
 
 echo; echo "### test user limit enforcement"
-_scratch_mount "-o usrquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota"
+_qmount
 type=u
 test_files
 test_enforcement
@@ -122,8 +123,8 @@ cleanup_files
 _scratch_unmount 2>/dev/null
 
 echo; echo "### test group limit enforcement"
-_scratch_mount "-o grpquota"
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "grpquota"
+_qmount
 type=g
 test_files
 test_enforcement
tests/generic/231 +2 -4
index ce7e62ea1886..02910523d0b5 100755
@@ -47,10 +47,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _fsx 1; then
 	_scratch_unmount 2>/dev/null
tests/generic/232 +2 -4
index c903a5619045..21375809d299 100755
@@ -44,10 +44,8 @@ _require_scratch
 _require_quota
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 _fsstress
 _check_quota_usage
tests/generic/233 +2 -4
index 3fc1b63abb24..4606f3bde2ab 100755
@@ -59,10 +59,8 @@ _require_quota
 _require_user
 
 _scratch_mkfs > $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 
 2>/dev/null
 

_fsstress

tests/generic/234 +2 -3
index 4b25fc6507cc..2c596492a3e0 100755
@@ -66,9 +66,8 @@ _require_quota
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon -u -g $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 test_setting
 _scratch_unmount
 
tests/generic/235 +2 -3
index 037c29e806db..7a616650fc8f 100755
@@ -25,9 +25,8 @@ do_repquota()
 
 
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 
 touch $SCRATCH_MNT/testfile
 chown $qa_user:$qa_user $SCRATCH_MNT/testfile
tests/generic/244 +0 -1
index b68035129c82..989bb4f5385e 100755
@@ -66,7 +66,6 @@ done
 # remount just for kicks, make sure we get it off disk
 _scratch_unmount
 _qmount
-quotaon $SCRATCH_MNT 2>/dev/null
 
 # Read them back by iterating based on quotas returned.
 # This should match what we set, even if we don't directly
tests/generic/270 +2 -4
index c3d5127a0b51..9ac829a7379f 100755
@@ -62,10 +62,8 @@ _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.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
+_qmount_option "usrquota,grpquota"
+_qmount
 
 if ! _workout; then
tests/generic/270 +0 -0
 	_scratch_unmount 2>/dev/null
tests/generic/280 +2 -3
index 3108fd23fb70..fae0a02145cf 100755
@@ -34,9 +34,8 @@ _require_freeze
 
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount "-o usrquota,grpquota"
-quotacheck -u -g $SCRATCH_MNT 2>/dev/null
-quotaon $SCRATCH_MNT 2>/dev/null
+_qmount_option "usrquota,grpquota"
+_qmount
 xfs_freeze -f $SCRATCH_MNT
 setquota -u root 1 2 3 4 $SCRATCH_MNT &
 pid=$!
tests/generic/400 +1 -2
index 77970da69a41..ef27c254167c 100755
@@ -22,7 +22,7 @@ _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
 
-MOUNT_OPTIONS="-o usrquota,grpquota"
+_qmount_option "usrquota,grpquota"
 _qmount
 _require_getnextquota
 
--

2.48.1