* [PATCH 1/3] xfs: test rtalloc alignment and math errors
2021-03-23 4:20 [PATCHSET 0/3] fstests: test kernel regressions fixed in 5.12 Darrick J. Wong
@ 2021-03-23 4:20 ` Darrick J. Wong
2021-03-25 8:57 ` Chandan Babu R
2021-03-23 4:20 ` [PATCH 2/3] common/rc: refactor _require_{ext2,tmpfs} helpers Darrick J. Wong
2021-03-23 4:20 ` [PATCH 3/3] generic: test a deadlock in xfs_rename when whiteing out files Darrick J. Wong
2 siblings, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2021-03-23 4:20 UTC (permalink / raw)
To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan
From: Darrick J. Wong <djwong@kernel.org>
Add a couple of regression tests for "xfs: make sure the rt allocator
doesn't run off the end" and "xfs: ensure that fpunch, fcollapse, and
finsert operations are aligned to rt extent size".
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
tests/xfs/759 | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/759.out | 2 +
tests/xfs/760 | 68 +++++++++++++++++++++++++++++++++++
tests/xfs/760.out | 9 +++++
tests/xfs/group | 2 +
5 files changed, 183 insertions(+)
create mode 100755 tests/xfs/759
create mode 100644 tests/xfs/759.out
create mode 100755 tests/xfs/760
create mode 100644 tests/xfs/760.out
diff --git a/tests/xfs/759 b/tests/xfs/759
new file mode 100755
index 00000000..d9031808
--- /dev/null
+++ b/tests/xfs/759
@@ -0,0 +1,102 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle. All Rights Reserved.
+#
+# FS QA Test No. 759
+#
+# This is a regression test for commit 2a6ca4baed62 ("xfs: make sure the rt
+# allocator doesn't run off the end") which fixes an overflow error in the
+# _near realtime allocator. If the rt bitmap ends exactly at the end of a
+# block and the number of rt extents is large enough to allow an allocation
+# request larger than the maximum extent size, it's possible that during a
+# large allocation request, the allocator will fail to constrain maxlen on the
+# second run through the loop, and the rt bitmap range check will run right off
+# the end of the rtbitmap file. When this happens, xfs triggers a verifier
+# error and returns EFSCORRUPTED.
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_realtime
+_require_test_program "punch-alternating"
+
+rm -f $seqres.full
+
+# Format filesystem to get the block size
+_scratch_mkfs > $seqres.full
+_scratch_mount >> $seqres.full
+
+blksz=$(_get_block_size $SCRATCH_MNT)
+rextsize=$($XFS_INFO_PROG $SCRATCH_MNT | grep realtime.*extsz | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g')
+rextblks=$((rextsize / blksz))
+
+echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
+
+_scratch_unmount
+
+# Format filesystem with a realtime volume whose size fits the following:
+# 1. Longer than (XFS MAXEXTLEN * blocksize) bytes so that a large fallocate
+# request can create a maximally sized data fork extent mapping and then
+# ask the allocator for even more blocks.
+# 2. Exactly a multiple of (NBBY * blksz * rextsize) bytes.
+
+rtsize1=$((2097151 * blksz))
+rtsize2=$((8 * blksz * rextsize))
+rtsize=$(( $(blockdev --getsz $SCRATCH_RTDEV) * 512 ))
+
+echo "rtsize1 $rtsize1 rtsize2 $rtsize2 rtsize $rtsize" >> $seqres.full
+
+test $rtsize -gt $rtsize1 || \
+ _notrun "scratch rt device too small, need $rtsize1 bytes"
+test $rtsize -gt $rtsize2 || \
+ _notrun "scratch rt device too small, need $rtsize2 bytes"
+
+rtsize=$((rtsize - (rtsize % rtsize2)))
+
+echo "rt size will be $rtsize" >> $seqres.full
+
+_scratch_mkfs -r size=$rtsize >> $seqres.full
+_scratch_mount >> $seqres.full
+
+# Make sure the root directory has rtinherit set so our test file will too
+$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
+
+# Allocate some stuff at the start, to force the first falloc of the ouch file
+# to happen somewhere in the middle of the rt volume
+$XFS_IO_PROG -f -c 'falloc 0 64m' "$SCRATCH_MNT/b"
+$here/src/punch-alternating -i $((rextblks * 2)) -s $((rextblks)) "$SCRATCH_MNT/b"
+
+avail="$(df -P "$SCRATCH_MNT" | awk 'END {print $4}')"1
+toobig="$((avail * 2))"
+
+# falloc the ouch file in the middle of the rt extent to exercise the near
+# allocator in the last step.
+$XFS_IO_PROG -f -c 'falloc 0 1g' "$SCRATCH_MNT/ouch"
+
+# Try to get the near allocator to overflow on an allocation that matches
+# exactly one of the rtsummary size levels. This should return ENOSPC and
+# not EFSCORRUPTED.
+$XFS_IO_PROG -f -c "falloc 0 ${toobig}k" "$SCRATCH_MNT/ouch"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/759.out b/tests/xfs/759.out
new file mode 100644
index 00000000..df693d50
--- /dev/null
+++ b/tests/xfs/759.out
@@ -0,0 +1,2 @@
+QA output created by 759
+fallocate: No space left on device
diff --git a/tests/xfs/760 b/tests/xfs/760
new file mode 100755
index 00000000..7f2b52d4
--- /dev/null
+++ b/tests/xfs/760
@@ -0,0 +1,68 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle. All Rights Reserved.
+#
+# FS QA Test No. 760
+#
+# Make sure we validate realtime extent size alignment for fallocate modes.
+# This is a regression test for fe341eb151ec ("xfs: ensure that fpunch,
+# fcollapse, and finsert operations are aligned to rt extent size")
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_realtime
+_require_xfs_io_command "fcollapse"
+_require_xfs_io_command "finsert"
+_require_xfs_io_command "funshare"
+_require_xfs_io_command "fzero"
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+# Format filesystem with a 256k realtime extent size
+_scratch_mkfs -r extsize=256k > $seqres.full
+_scratch_mount >> $seqres.full
+
+blksz=$(_get_block_size $SCRATCH_MNT)
+rextsize=$($XFS_INFO_PROG $SCRATCH_MNT | grep realtime.*extsz | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g')
+rextblks=$((rextsize / blksz))
+
+echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
+
+# Make sure the root directory has rtinherit set so our test file will too
+$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
+
+sz=$((rextsize * 100))
+range="$((blksz * 3)) $blksz"
+
+for verb in fpunch finsert fcollapse fzero funshare falloc; do
+ echo "test $verb"
+ $XFS_IO_PROG -f -c "falloc 0 $sz" "$SCRATCH_MNT/b"
+ $XFS_IO_PROG -f -c "$verb $range" "$SCRATCH_MNT/b"
+ rm -f "$SCRATCH_MNT/b"
+ _scratch_cycle_mount
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/760.out b/tests/xfs/760.out
new file mode 100644
index 00000000..3d73c6fa
--- /dev/null
+++ b/tests/xfs/760.out
@@ -0,0 +1,9 @@
+QA output created by 760
+test fpunch
+test finsert
+fallocate: Invalid argument
+test fcollapse
+fallocate: Invalid argument
+test fzero
+test funshare
+test falloc
diff --git a/tests/xfs/group b/tests/xfs/group
index 219a4cfe..eebe7dde 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -515,3 +515,5 @@
536 auto quick reflink
537 auto quick
538 auto stress
+759 auto quick rw realtime
+760 auto quick rw realtime collapse insert unshare zero prealloc
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] common/rc: refactor _require_{ext2,tmpfs} helpers
2021-03-23 4:20 [PATCHSET 0/3] fstests: test kernel regressions fixed in 5.12 Darrick J. Wong
2021-03-23 4:20 ` [PATCH 1/3] xfs: test rtalloc alignment and math errors Darrick J. Wong
@ 2021-03-23 4:20 ` Darrick J. Wong
2021-03-23 4:20 ` [PATCH 3/3] generic: test a deadlock in xfs_rename when whiteing out files Darrick J. Wong
2 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2021-03-23 4:20 UTC (permalink / raw)
To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan
From: Darrick J. Wong <djwong@kernel.org>
Combine these two helpers into a single generic function so that we can
use it in the next patch to test a regression when running overlayfs
atop xfs.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
common/rc | 23 +++++------------------
tests/overlay/025 | 2 +-
tests/overlay/106 | 2 +-
tests/overlay/107 | 2 +-
tests/overlay/108 | 2 +-
tests/overlay/109 | 2 +-
tests/xfs/049 | 2 +-
7 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/common/rc b/common/rc
index 6d1757da..434cd583 100644
--- a/common/rc
+++ b/common/rc
@@ -1766,26 +1766,13 @@ _require_loop()
fi
}
-# this test requires ext2 filesystem support
+# this test requires kernel support for a secondary filesystem
#
-_require_ext2()
+_require_extra_fs()
{
- modprobe ext2 >/dev/null 2>&1
- if grep ext2 /proc/filesystems >/dev/null 2>&1
- then
- :
- else
- _notrun "This test requires ext2 filesystem support"
- fi
-}
-
-# this test requires tmpfs filesystem support
-#
-_require_tmpfs()
-{
- modprobe tmpfs >/dev/null 2>&1
- grep -q tmpfs /proc/filesystems ||
- _notrun "this test requires tmpfs support"
+ modprobe "$1" >/dev/null 2>&1
+ grep -q -w "$1" /proc/filesystems ||
+ _notrun "this test requires $1 support"
}
# this test requires that (large) loopback device files are not in use
diff --git a/tests/overlay/025 b/tests/overlay/025
index 979bd98e..c5f328c8 100755
--- a/tests/overlay/025
+++ b/tests/overlay/025
@@ -42,7 +42,7 @@ rm -f $seqres.full
# Modify as appropriate.
_supported_fs overlay
_require_user
-_require_tmpfs
+_require_extra_fs tmpfs
# create a tmpfs in $TEST_DIR
tmpfsdir=$TEST_DIR/tmpfs
diff --git a/tests/overlay/106 b/tests/overlay/106
index 28e9a819..0b3e0c98 100755
--- a/tests/overlay/106
+++ b/tests/overlay/106
@@ -27,7 +27,7 @@ rm -f $seqres.full
# real QA test starts here
_supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
_require_test
_require_scratch
_require_unionmount_testsuite
diff --git a/tests/overlay/107 b/tests/overlay/107
index 733a5556..89fde9de 100755
--- a/tests/overlay/107
+++ b/tests/overlay/107
@@ -27,7 +27,7 @@ rm -f $seqres.full
# real QA test starts here
_supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
_require_test
_require_scratch
_require_unionmount_testsuite
diff --git a/tests/overlay/108 b/tests/overlay/108
index e757e0e4..ae367a5c 100755
--- a/tests/overlay/108
+++ b/tests/overlay/108
@@ -27,7 +27,7 @@ rm -f $seqres.full
# real QA test starts here
_supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
_require_test
_require_scratch
_require_unionmount_testsuite
diff --git a/tests/overlay/109 b/tests/overlay/109
index d49080be..df036616 100755
--- a/tests/overlay/109
+++ b/tests/overlay/109
@@ -27,7 +27,7 @@ rm -f $seqres.full
# real QA test starts here
_supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
_require_test
_require_scratch
_require_unionmount_testsuite
diff --git a/tests/xfs/049 b/tests/xfs/049
index 67739265..16bc788d 100755
--- a/tests/xfs/049
+++ b/tests/xfs/049
@@ -46,7 +46,7 @@ _require_nonexternal
_require_scratch_nocheck
_require_no_large_scratch_dev
_require_loop
-_require_ext2
+_require_extra_fs ext2
rm -f $seqres.full
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] generic: test a deadlock in xfs_rename when whiteing out files
2021-03-23 4:20 [PATCHSET 0/3] fstests: test kernel regressions fixed in 5.12 Darrick J. Wong
2021-03-23 4:20 ` [PATCH 1/3] xfs: test rtalloc alignment and math errors Darrick J. Wong
2021-03-23 4:20 ` [PATCH 2/3] common/rc: refactor _require_{ext2,tmpfs} helpers Darrick J. Wong
@ 2021-03-23 4:20 ` Darrick J. Wong
2 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2021-03-23 4:20 UTC (permalink / raw)
To: djwong, guaneryu; +Cc: wenli xie, linux-xfs, fstests, guan
From: Darrick J. Wong <djwong@kernel.org>
wenli xie reported a buffer cache deadlock when an overlayfs is mounted
atop xfs and overlayfs tries to replace a single-nlink file with a
whiteout file. This test reproduces that deadlock.
Reported-by: wenli xie <wlxie7296@gmail.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
tests/generic/1300 | 108 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/1300.out | 2 +
tests/generic/group | 1
3 files changed, 111 insertions(+)
create mode 100755 tests/generic/1300
create mode 100644 tests/generic/1300.out
diff --git a/tests/generic/1300 b/tests/generic/1300
new file mode 100755
index 00000000..7c47e732
--- /dev/null
+++ b/tests/generic/1300
@@ -0,0 +1,108 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle. All Rights Reserved.
+#
+# FS QA Test No. 1300
+#
+# Reproducer for a deadlock in xfs_rename reported by Wenli Xie.
+#
+# When overlayfs is running on top of xfs and the user unlinks a file in the
+# overlay, overlayfs will create a whiteout inode and ask us to "rename" the
+# whiteout file atop the one being unlinked. If the file being unlinked loses
+# its one nlink, we then have to put the inode on the unlinked list.
+#
+# This requires us to grab the AGI buffer of the whiteout inode to take it
+# off the unlinked list (which is where whiteouts are created) and to grab
+# the AGI buffer of the file being deleted. If the whiteout was created in
+# a higher numbered AG than the file being deleted, we'll lock the AGIs in
+# the wrong order and deadlock.
+#
+# Note that this test doesn't do anything xfs-specific so it's a generic test.
+# This is a regression test for commit 6da1b4b1ab36 ("xfs: fix an ABBA deadlock
+# in xfs_rename").
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ stop_workers
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+
+# real QA test starts here
+_supported_fs generic
+_require_scratch
+test "$FSTYP" = "overlay" && _notrun "Test does not apply to overlayfs."
+_require_extra_fs overlay
+
+rm -f $seqres.full
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+_supports_filetype $SCRATCH_MNT || _notrun "overlayfs test requires d_type"
+
+mkdir $SCRATCH_MNT/lowerdir
+mkdir $SCRATCH_MNT/lowerdir1
+mkdir $SCRATCH_MNT/lowerdir/etc
+mkdir $SCRATCH_MNT/workers
+echo salts > $SCRATCH_MNT/lowerdir/etc/access.conf
+touch $SCRATCH_MNT/running
+
+stop_workers() {
+ test -e $SCRATCH_MNT/running || return
+ rm -f $SCRATCH_MNT/running
+
+ while [ "$(ls $SCRATCH_MNT/workers/ | wc -l)" -gt 0 ]; do
+ wait
+ done
+}
+
+worker() {
+ local tag="$1"
+ local mergedir="$SCRATCH_MNT/merged$tag"
+ local l="lowerdir=$SCRATCH_MNT/lowerdir:$SCRATCH_MNT/lowerdir1"
+ local u="upperdir=$SCRATCH_MNT/upperdir$tag"
+ local w="workdir=$SCRATCH_MNT/workdir$tag"
+ local i="index=off,nfs_export=off"
+
+ touch $SCRATCH_MNT/workers/$tag
+ while test -e $SCRATCH_MNT/running; do
+ rm -rf $SCRATCH_MNT/merged$tag
+ rm -rf $SCRATCH_MNT/upperdir$tag
+ rm -rf $SCRATCH_MNT/workdir$tag
+ mkdir $SCRATCH_MNT/merged$tag
+ mkdir $SCRATCH_MNT/workdir$tag
+ mkdir $SCRATCH_MNT/upperdir$tag
+
+ mount -t overlay overlay -o "$l,$u,$w,$i" $mergedir
+ mv $mergedir/etc/access.conf $mergedir/etc/access.conf.bak
+ touch $mergedir/etc/access.conf
+ mv $mergedir/etc/access.conf $mergedir/etc/access.conf.bak
+ touch $mergedir/etc/access.conf
+ umount $mergedir
+ done
+ rm -f $SCRATCH_MNT/workers/$tag
+}
+
+for i in $(seq 0 $((4 + LOAD_FACTOR)) ); do
+ worker $i &
+done
+
+sleep $((30 * TIME_FACTOR))
+stop_workers
+
+echo Silence is golden.
+# success, all done
+status=0
+exit
diff --git a/tests/generic/1300.out b/tests/generic/1300.out
new file mode 100644
index 00000000..5805d30d
--- /dev/null
+++ b/tests/generic/1300.out
@@ -0,0 +1,2 @@
+QA output created by 1300
+Silence is golden.
diff --git a/tests/generic/group b/tests/generic/group
index 7c7531d1..9e126b8c 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -633,3 +633,4 @@
628 auto quick rw clone
629 auto quick rw copy_range
630 auto quick rw dedupe clone
+1300 auto rw overlay rename
^ permalink raw reply related [flat|nested] 5+ messages in thread