Skip to contentSkip to conversation

xfs/220: fix quotarm syscall test

PATCH In review Darrick J. Wong 2 participants 4 messages Jan 5, 2022 – Jan 6, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs/220: fix quotarm syscall test

From: Darrick J. Wong <[email protected]>

In commit 6ba125c9, we tried to adjust this fstest to deal with the removal of the ability to turn off quota accounting via the Q_XQUOTAOFF system call.

Unfortunately, the changes made to this test make it nonfunctional on those newer kernels, since the Q_XQUOTARM command returns EINVAL if quota accounting is turned on, and the changes filter out the EINVAL error string.

Doing this wasn't /incorrect/, because, very narrowly speaking, the intent of this test is to guard against Q_XQUOTARM returning ENOSYS when quota has been enabled. However, this also means that we no longer test Q_XQUOTARM's ability to truncate the quota files at all.

So, fix this test to deal with the loss of quotaoff in the same way that the others do -- if accounting is still enabled after the 'off' command, cycle the mount so that Q_XQUOTARM actually truncates the files.

While we're at it, enhance the test to check that XQUOTARM actually truncated the quota files.

Fixes 6ba125c9 ("xfs/220: avoid failure when disabling quota accounting is not supported")
---
 tests/xfs/220 |   28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
tests/xfs/220 +21 -7
index 241a7abd..cfa90d3a 100755
@@ -52,14 +52,28 @@ _scratch_mkfs_xfs >/dev/null 2>&1
 # mount  with quotas enabled
 _scratch_mount -o uquota
 
-# turn off quota and remove space allocated to the quota files
+# turn off quota accounting...
+$XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
+
+# ...but if the kernel doesn't support turning off accounting, remount with
+# noquota option to turn it off...
+if $XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_DEV | grep -q 'Accounting: ON'; then
+	_scratch_unmount
+	_scratch_mount -o noquota
+fi
+
+before_freesp=$(_get_available_space $SCRATCH_MNT)
+
+# ...and remove space allocated to the quota files
 # (this used to give wrong ENOSYS returns in 2.6.31)
-#
-# The sed expression below replaces a notrun to cater for kernels that have
-# removed the ability to disable quota accounting at runtime.  On those
-# kernel this test is rather useless, and in a few years we can drop it.
-$XFS_QUOTA_PROG -x -c off -c remove $SCRATCH_DEV 2>&1 | \
-	sed -e '/XFS_QUOTARM: Invalid argument/d'
+$XFS_QUOTA_PROG -x -c remove $SCRATCH_DEV
+
+# Make sure we actually freed the space used by dquot 0
+after_freesp=$(_get_available_space $SCRATCH_MNT)
+if [ $before_freesp -ge $after_freesp ]; then
+	echo "before: $before_freesp; after: $after_freesp" >> $seqres.full
+	echo "expected more free space after Q_XQUOTARM"
+fi
 
 # and unmount again
 _scratch_unmount
#1 lore raw
Quoted 54 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

In commit 6ba125c9, we tried to adjust this fstest to deal with the removal of the ability to turn off quota accounting via the Q_XQUOTAOFF system call.

Unfortunately, the changes made to this test make it nonfunctional on those newer kernels, since the Q_XQUOTARM command returns EINVAL if quota accounting is turned on, and the changes filter out the EINVAL error string.

Doing this wasn't /incorrect/, because, very narrowly speaking, the intent of this test is to guard against Q_XQUOTARM returning ENOSYS when quota has been enabled. However, this also means that we no longer test Q_XQUOTARM's ability to truncate the quota files at all.

So, fix this test to deal with the loss of quotaoff in the same way that the others do -- if accounting is still enabled after the 'off' command, cycle the mount so that Q_XQUOTARM actually truncates the files.

While we're at it, enhance the test to check that XQUOTARM actually truncated the quota files.

Fixes 6ba125c9 ("xfs/220: avoid failure when disabling quota accounting is not supported")
---
  tests/xfs/220 |   28 +++++++++++++++++++++-------
  1 file changed, 21 insertions(+), 7 deletions(-)
tests/xfs/220 +13 -3
index 241a7abd..cfa90d3a 100755
@@ -52,14 +52,28 @@ _scratch_mkfs_xfs>/dev/null 2>&1
  # mount  with quotas enabled
  _scratch_mount -o uquota
 
-# turn off quota and remove space allocated to the quota files
+# turn off quota accounting...
+$XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
+
+# ...but if the kernel doesn't support turning off accounting, remount with
+# noquota option to turn it off...
+if $XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_DEV | grep -q 'Accounting: ON'; then
+	_scratch_unmount
+	_scratch_mount -o noquota
+fi
+
+before_freesp=$(_get_available_space $SCRATCH_MNT)
+
+# ...and remove space allocated to the quota files
  # (this used to give wrong ENOSYS returns in 2.6.31)
-#
-# The sed expression below replaces a notrun to cater for kernels that have

tests/xfs/220 _scratch_mkfs_xfs>/dev/null 2>&1 · line 74

Quoted 10 lines
tests/xfs/220 +6 -4
-# removed the ability to disable quota accounting at runtime.  On those
-# kernel this test is rather useless, and in a few years we can drop it.
-$XFS_QUOTA_PROG -x -c off -c remove $SCRATCH_DEV 2>&1 | \
-	sed -e '/XFS_QUOTARM: Invalid argument/d'
+$XFS_QUOTA_PROG -x -c remove $SCRATCH_DEV
+
+# Make sure we actually freed the space used by dquot 0
+after_freesp=$(_get_available_space $SCRATCH_MNT)
+if [ $before_freesp -ge $after_freesp ]; then
+	echo "before: $before_freesp; after: $after_freesp">>  $seqres.full

I prefer to move this info outside the if. So even case pass, I still can see the difference in seqres.full.

tests/xfs/220 _scratch_mkfs_xfs >/dev/null 2>&1 · line 75

Quoted 1 line
tests/xfs/220 +1 -0
+	echo "expected more free space after Q_XQUOTARM"

Do you forget to add this into 220.out?

Also, I try this patch and add some output about delta. It seems before_value greater than after value.

#Make sure we actually freed the space used by dquot 0
after_freesp=$(_get_available_space $SCRATCH_MNT) delta=$(($before_freesp - $after_freesp))
echo "before: $before_freesp; after: $after_freesp, delta: $delta" >> $seqres.full
if [ $delta -ge 0 ]; then
echo "expected more free space after Q_XQUOTARM"
fi

MOUNT_OPTIONS = -o defaults
before: 21280804864; after: 21280808960, delta: -4096

Best Regards
Yang Xu

Quoted 4 lines
tests/xfs/220 +1 -0
+fi
 
  # and unmount again
  _scratch_unmount
#2 lore raw
Quoted 67 lines · on 2022/1/6 9:34, [email protected] wrote:
Quoted 54 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

In commit 6ba125c9, we tried to adjust this fstest to deal with the removal of the ability to turn off quota accounting via the Q_XQUOTAOFF system call.

Unfortunately, the changes made to this test make it nonfunctional on those newer kernels, since the Q_XQUOTARM command returns EINVAL if quota accounting is turned on, and the changes filter out the EINVAL error string.

Doing this wasn't /incorrect/, because, very narrowly speaking, the intent of this test is to guard against Q_XQUOTARM returning ENOSYS when quota has been enabled. However, this also means that we no longer test Q_XQUOTARM's ability to truncate the quota files at all.

So, fix this test to deal with the loss of quotaoff in the same way that the others do -- if accounting is still enabled after the 'off' command, cycle the mount so that Q_XQUOTARM actually truncates the files.

While we're at it, enhance the test to check that XQUOTARM actually truncated the quota files.

Fixes 6ba125c9 ("xfs/220: avoid failure when disabling quota accounting is not supported")
---
   tests/xfs/220 |   28 +++++++++++++++++++++-------
   1 file changed, 21 insertions(+), 7 deletions(-)
tests/xfs/220 +13 -3
index 241a7abd..cfa90d3a 100755
@@ -52,14 +52,28 @@ _scratch_mkfs_xfs>/dev/null 2>&1
   # mount  with quotas enabled
   _scratch_mount -o uquota
 
-# turn off quota and remove space allocated to the quota files
+# turn off quota accounting...
+$XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
+
+# ...but if the kernel doesn't support turning off accounting, remount with
+# noquota option to turn it off...
+if $XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_DEV | grep -q 'Accounting: ON'; then
+	_scratch_unmount
+	_scratch_mount -o noquota
+fi
+
+before_freesp=$(_get_available_space $SCRATCH_MNT)
+
+# ...and remove space allocated to the quota files
   # (this used to give wrong ENOSYS returns in 2.6.31)
-#
-# The sed expression below replaces a notrun to cater for kernels that have

tests/xfs/220 _scratch_mkfs_xfs>/dev/null 2>&1 · line 74

Quoted 10 lines
tests/xfs/220 +6 -4
-# removed the ability to disable quota accounting at runtime.  On those
-# kernel this test is rather useless, and in a few years we can drop it.
-$XFS_QUOTA_PROG -x -c off -c remove $SCRATCH_DEV 2>&1 | \
-	sed -e '/XFS_QUOTARM: Invalid argument/d'
+$XFS_QUOTA_PROG -x -c remove $SCRATCH_DEV
+
+# Make sure we actually freed the space used by dquot 0
+after_freesp=$(_get_available_space $SCRATCH_MNT)
+if [ $before_freesp -ge $after_freesp ]; then
+	echo "before: $before_freesp; after: $after_freesp">>   $seqres.full

I prefer to move this info outside the if. So even case pass, I still can see the difference in seqres.full.

Quoted 2 lines

tests/xfs/220 _scratch_mkfs_xfs >/dev/null 2>&1 · line 75

Quoted 1 line
tests/xfs/220 +1 -0
+	echo "expected more free space after Q_XQUOTARM"

Do you forget to add this into 220.out?

Sorry, _get_available_space is designed for free space. I misunderstand it.

Just one nit, can we move the $seqres.full code outside the if?

after_freesp=$(_get_available_space $SCRATCH_MNT) delta=$(($after_freesp - $before_freesp))
echo "before_freesp: $before_freesp; after_freesp: $after_freesp, delta:
$delta" >> $seqres.full
if [ $delta -le 0 ]; then
echo "expected more free space after Q_XQUOTARM"
fi

Best Regards
Yang Xu

Quoted 24 lines

Also, I try this patch and add some output about delta. It seems before_value greater than after value.

#Make sure we actually freed the space used by dquot 0
after_freesp=$(_get_available_space $SCRATCH_MNT) delta=$(($before_freesp - $after_freesp))
echo "before: $before_freesp; after: $after_freesp, delta: $delta">> $seqres.full
if [ $delta -ge 0 ]; then
echo "expected more free space after Q_XQUOTARM"
fi

MOUNT_OPTIONS = -o defaults
before: 21280804864; after: 21280808960, delta: -4096

Best Regards
Yang Xu

Quoted 4 lines
tests/xfs/220 +1 -0
+fi
 
   # and unmount again
   _scratch_unmount
#3 lore raw
Quoted 74 lines · On Thu, Jan 06, 2022 at 01:55:01AM +0000, [email protected] wrote:
Quoted 67 lines · on 2022/1/6 9:34, [email protected] wrote:
Quoted 54 lines · Darrick J. Wong

From: Darrick J. Wong<[email protected]>

In commit 6ba125c9, we tried to adjust this fstest to deal with the removal of the ability to turn off quota accounting via the Q_XQUOTAOFF system call.

Unfortunately, the changes made to this test make it nonfunctional on those newer kernels, since the Q_XQUOTARM command returns EINVAL if quota accounting is turned on, and the changes filter out the EINVAL error string.

Doing this wasn't /incorrect/, because, very narrowly speaking, the intent of this test is to guard against Q_XQUOTARM returning ENOSYS when quota has been enabled. However, this also means that we no longer test Q_XQUOTARM's ability to truncate the quota files at all.

So, fix this test to deal with the loss of quotaoff in the same way that the others do -- if accounting is still enabled after the 'off' command, cycle the mount so that Q_XQUOTARM actually truncates the files.

While we're at it, enhance the test to check that XQUOTARM actually truncated the quota files.

Fixes 6ba125c9 ("xfs/220: avoid failure when disabling quota accounting is not supported")
---
   tests/xfs/220 |   28 +++++++++++++++++++++-------
   1 file changed, 21 insertions(+), 7 deletions(-)
tests/xfs/220 +13 -3
index 241a7abd..cfa90d3a 100755
@@ -52,14 +52,28 @@ _scratch_mkfs_xfs>/dev/null 2>&1
   # mount  with quotas enabled
   _scratch_mount -o uquota
 
-# turn off quota and remove space allocated to the quota files
+# turn off quota accounting...
+$XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
+
+# ...but if the kernel doesn't support turning off accounting, remount with
+# noquota option to turn it off...
+if $XFS_QUOTA_PROG -x -c 'state -u' $SCRATCH_DEV | grep -q 'Accounting: ON'; then
+	_scratch_unmount
+	_scratch_mount -o noquota
+fi
+
+before_freesp=$(_get_available_space $SCRATCH_MNT)
+
+# ...and remove space allocated to the quota files
   # (this used to give wrong ENOSYS returns in 2.6.31)
-#
-# The sed expression below replaces a notrun to cater for kernels that have

tests/xfs/220 _scratch_mkfs_xfs>/dev/null 2>&1 · line 74

Quoted 10 lines
tests/xfs/220 +6 -4
-# removed the ability to disable quota accounting at runtime.  On those
-# kernel this test is rather useless, and in a few years we can drop it.
-$XFS_QUOTA_PROG -x -c off -c remove $SCRATCH_DEV 2>&1 | \
-	sed -e '/XFS_QUOTARM: Invalid argument/d'
+$XFS_QUOTA_PROG -x -c remove $SCRATCH_DEV
+
+# Make sure we actually freed the space used by dquot 0
+after_freesp=$(_get_available_space $SCRATCH_MNT)
+if [ $before_freesp -ge $after_freesp ]; then
+	echo "before: $before_freesp; after: $after_freesp">>   $seqres.full

I prefer to move this info outside the if. So even case pass, I still can see the difference in seqres.full.

Quoted 2 lines

tests/xfs/220 _scratch_mkfs_xfs >/dev/null 2>&1 · line 75

Quoted 1 line
tests/xfs/220 +1 -0
+	echo "expected more free space after Q_XQUOTARM"

Do you forget to add this into 220.out?

Sorry, _get_available_space is designed for free space. I misunderstand it.

Just one nit, can we move the $seqres.full code outside the if?

Quoted 7 lines

after_freesp=$(_get_available_space $SCRATCH_MNT) delta=$(($after_freesp - $before_freesp))
echo "before_freesp: $before_freesp; after_freesp: $after_freesp, delta:
$delta" >> $seqres.full
if [ $delta -le 0 ]; then
echo "expected more free space after Q_XQUOTARM"
fi

Yes, I'll do that.

--D

Quoted 26 lines

Best Regards
Yang Xu

Quoted 24 lines

Also, I try this patch and add some output about delta. It seems before_value greater than after value.

#Make sure we actually freed the space used by dquot 0
after_freesp=$(_get_available_space $SCRATCH_MNT) delta=$(($before_freesp - $after_freesp))
echo "before: $before_freesp; after: $after_freesp, delta: $delta">> $seqres.full
if [ $delta -ge 0 ]; then
echo "expected more free space after Q_XQUOTARM"
fi

MOUNT_OPTIONS = -o defaults
before: 21280804864; after: 21280808960, delta: -4096

Best Regards
Yang Xu

Quoted 4 lines
tests/xfs/220 +1 -0
+fi
 
   # and unmount again
   _scratch_unmount