aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-01-11 13:50:24 -0800
committerEryu Guan <guaneryu@gmail.com>2022-01-16 12:58:06 +0800
commit3925a4ec9d478e87ac242cdffc243b86de5a08aa (patch)
treeb705641884530b4f25ef791d4958809d97e4e68a
parent3f79f632b07371f486cf9754c76ef53b4c579018 (diff)
downloadxfstests-dev-3925a4ec9d478e87ac242cdffc243b86de5a08aa.tar.gz
xfs/220: fix quotarm syscall test
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") Cc: xuyang2018.jy@fujitsu.com Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by:Yang Xu <xuyang2018.jy@fujitsu.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-xtests/xfs/22030
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/xfs/220 b/tests/xfs/220
index 241a7abd58..88eedf5161 100755
--- a/tests/xfs/220
+++ b/tests/xfs/220
@@ -52,14 +52,30 @@ _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)
+delta=$((after_freesp - before_freesp))
+
+echo "freesp $before_freesp -> $after_freesp ($delta)" >> $seqres.full
+if [ $before_freesp -ge $after_freesp ]; then
+ echo "expected Q_XQUOTARM to free space"
+fi
# and unmount again
_scratch_unmount