linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* stop overriding SCRATCH_{,LOG,RT}DEV
@ 2025-12-10  5:46 Christoph Hellwig
  2025-12-10  5:46 ` [PATCH 01/12] dmflakey: override SCRATCH_DEV in _init_flakey Christoph Hellwig
                   ` (11 more replies)
  0 siblings, 12 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Hi all,

this series cleans up various tests to get out of the business of
overriding the scratch devices setup.  This is not only generally a
little ugly, but breaks when mkfs options are incompatible with the
synthesized setups.

My prime example right now are two zoned XFS options:  -r rtreserved,
which only works for zoned RT devices, and breaks as soon as we're
running on non-RT or non-Zoned setups, and -r rtstart which only works
for internal RT zoned RT devices, and breaks as soon as an actual
SCRATCH_RTDEV was used.  There's probably more that we've been
papering over with the try_ options and by scratch_mkfs dropping
options when they conflict.  I plan to remove the need for the latter
in a follow-on series as it leads to hard to debug bugs.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/12] dmflakey: override SCRATCH_DEV in _init_flakey
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10  5:46 ` [PATCH 02/12] ext4/006: call e2fsck directly Christoph Hellwig
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

_init_flakey already overrides SCRATCH_LOGDEV and SCRATCH_RTDEV so that
the XFS-specific helpers work fine with external devices.  Do the same
for SCRATCH_DEV itself, so that _scratch_mount and _scratch_unmount just
work, and so that _check_scratch_fs does not need to override the main
device.

This requires some small adjustments in how generic/741 checks that
mounting the underlying device fails, but the new version actually is
simpler than the old one, and in xfs/438 where we need to be careful
where to create the custome dm table.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 common/dmflakey       | 47 +++++++++++++++++++++----------------------
 tests/btrfs/056       |  6 +++---
 tests/btrfs/085       | 14 ++++++-------
 tests/btrfs/095       |  4 ++--
 tests/btrfs/098       |  4 ++--
 tests/btrfs/118       |  4 ++--
 tests/btrfs/119       |  4 ++--
 tests/btrfs/120       |  4 ++--
 tests/btrfs/159       |  4 ++--
 tests/btrfs/166       |  4 ++--
 tests/btrfs/201       |  8 ++++----
 tests/btrfs/209       |  4 ++--
 tests/btrfs/211       | 14 ++++++-------
 tests/btrfs/231       |  4 ++--
 tests/btrfs/233       | 20 +++++++++---------
 tests/btrfs/236       |  8 ++++----
 tests/btrfs/239       |  4 ++--
 tests/btrfs/240       |  4 ++--
 tests/btrfs/243       |  4 ++--
 tests/generic/034     |  4 ++--
 tests/generic/039     |  2 +-
 tests/generic/040     |  2 +-
 tests/generic/041     |  2 +-
 tests/generic/056     |  2 +-
 tests/generic/057     |  2 +-
 tests/generic/059     |  2 +-
 tests/generic/065     |  2 +-
 tests/generic/066     |  4 ++--
 tests/generic/073     |  2 +-
 tests/generic/090     |  2 +-
 tests/generic/101     |  2 +-
 tests/generic/104     |  4 ++--
 tests/generic/106     |  4 ++--
 tests/generic/107     |  4 ++--
 tests/generic/177     |  4 ++--
 tests/generic/311     | 12 +++++------
 tests/generic/321     | 20 +++++++++---------
 tests/generic/322     | 14 ++++++-------
 tests/generic/325     |  4 ++--
 tests/generic/335     |  4 ++--
 tests/generic/336     |  4 ++--
 tests/generic/341     |  4 ++--
 tests/generic/342     |  4 ++--
 tests/generic/343     |  4 ++--
 tests/generic/348     |  4 ++--
 tests/generic/376     |  4 ++--
 tests/generic/456     |  4 ++--
 tests/generic/479     |  4 ++--
 tests/generic/480     |  4 ++--
 tests/generic/481     |  4 ++--
 tests/generic/483     |  4 ++--
 tests/generic/489     |  4 ++--
 tests/generic/498     |  4 ++--
 tests/generic/501     |  4 ++--
 tests/generic/502     |  4 ++--
 tests/generic/509     |  4 ++--
 tests/generic/510     |  4 ++--
 tests/generic/512     |  4 ++--
 tests/generic/520     | 12 +++++------
 tests/generic/526     |  4 ++--
 tests/generic/527     |  4 ++--
 tests/generic/534     |  4 ++--
 tests/generic/535     |  4 ++--
 tests/generic/546     |  2 +-
 tests/generic/547     |  4 ++--
 tests/generic/552     |  4 ++--
 tests/generic/557     |  4 ++--
 tests/generic/588     |  4 ++--
 tests/generic/640     |  4 ++--
 tests/generic/677     |  4 ++--
 tests/generic/690     |  4 ++--
 tests/generic/695     |  4 ++--
 tests/generic/703     |  4 ++--
 tests/generic/741     | 16 +++++++--------
 tests/generic/741.out |  2 --
 tests/generic/745     |  2 +-
 tests/generic/764     |  4 ++--
 tests/generic/771     |  2 +-
 tests/generic/779     |  4 ++--
 tests/generic/782     |  4 ++--
 tests/generic/784     |  4 ++--
 tests/generic/785     |  4 ++--
 tests/xfs/051         |  4 ++--
 tests/xfs/438         | 10 +++++----
 tests/xfs/542         |  4 ++--
 tests/xfs/605         | 10 ++++-----
 86 files changed, 235 insertions(+), 236 deletions(-)

diff --git a/common/dmflakey b/common/dmflakey
index 7368a3e5b324..cb0359901c16 100644
--- a/common/dmflakey
+++ b/common/dmflakey
@@ -15,11 +15,19 @@ export FLAKEY_LOGNAME="flakey-logtest.$seq"
 _init_flakey()
 {
 	# Scratch device
-	local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
-	export FLAKEY_DEV="/dev/mapper/$FLAKEY_NAME"
-	FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 180 0"
-	FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 drop_writes"
-	FLAKEY_TABLE_ERROR="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes"
+	if [ -z "$NON_FLAKEY_DEV" ]; then
+		# Set up the device switch
+		local backing_dev="$SCRATCH_DEV"
+		export NON_FLAKEY_DEV="$SCRATCH_DEV"
+		SCRATCH_DEV=/dev/mapper/$FLAKEY_NAME
+	else
+		# Already set up; recreate tables
+		local backing_dev="$NON_FLAKEY_DEV"
+	fi
+	local BLK_DEV_SIZE=`blockdev --getsz $backing_dev`
+	FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $backing_dev 0 180 0"
+	FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 drop_writes"
+	FLAKEY_TABLE_ERROR="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 error_writes"
 	_dmsetup_create $FLAKEY_NAME --table "$FLAKEY_TABLE" || \
 		_fatal "failed to create flakey device"
 
@@ -62,32 +70,23 @@ _init_flakey()
 	fi
 }
 
-_mount_flakey()
-{
-	_scratch_options mount
-
-	mount -t $FSTYP $SCRATCH_OPTIONS $MOUNT_OPTIONS $FLAKEY_DEV $SCRATCH_MNT
-}
-
-_unmount_flakey()
-{
-	_unmount $SCRATCH_MNT
-}
-
 _cleanup_flakey()
 {
 	# If dmsetup load fails then we need to make sure to do resume here
 	# otherwise the umount will hang
 	test -n "$NON_FLAKEY_LOGDEV" && $DMSETUP_PROG resume $FLAKEY_LOGNAME &> /dev/null
 	test -n "$NON_FLAKEY_RTDEV" && $DMSETUP_PROG resume $FLAKEY_RTNAME &> /dev/null
-	$DMSETUP_PROG resume flakey-test > /dev/null 2>&1
+	test -n "$NON_FLAKEY_DEV" && $DMSETUP_PROG resume flakey-test > /dev/null 2>&1
 
 	_unmount $SCRATCH_MNT > /dev/null 2>&1
 
-	_dmsetup_remove $FLAKEY_NAME
+	test -n "$NON_FLAKEY_DEV" && _dmsetup_remove $FLAKEY_NAME
 	test -n "$NON_FLAKEY_LOGDEV" && _dmsetup_remove $FLAKEY_LOGNAME
 	test -n "$NON_FLAKEY_RTDEV" && _dmsetup_remove $FLAKEY_RTNAME
 
+	SCRATCH_DEV="$NON_FLAKEY_DEV"
+	unset NON_FLAKEY_DEV
+
 	if [ -n "$NON_FLAKEY_LOGDEV" ]; then
 		SCRATCH_LOGDEV="$NON_FLAKEY_LOGDEV"
 		unset NON_FLAKEY_LOGDEV
@@ -179,17 +178,17 @@ _flakey_drop_and_remount()
 {
 	# If the full environment is set up, configure ourselves for shutdown
 	type _prepare_for_eio_shutdown &>/dev/null && \
-		_prepare_for_eio_shutdown $FLAKEY_DEV
+		_prepare_for_eio_shutdown $SCRATCH_DEV
 
 	_load_flakey_table $FLAKEY_DROP_WRITES
-	_unmount_flakey
+	_scratch_unmount
 
 	if [ "x$1" = "xyes" ]; then
-		_check_scratch_fs $FLAKEY_DEV
+		_check_scratch_fs
 	fi
 
 	_load_flakey_table $FLAKEY_ALLOW_WRITES
-	_mount_flakey
+	_scratch_mount
 }
 
 _require_flakey_with_error_writes()
@@ -206,5 +205,5 @@ _require_flakey_with_error_writes()
 	_dmsetup_create $NAME --table "$TABLE" || \
 		_notrun "This test requires error_writes feature in dm-flakey"
 
-	_cleanup_flakey
+	_dmsetup_remove $FLAKEY_NAME
 }
diff --git a/tests/btrfs/056 b/tests/btrfs/056
index f7557f4a41a6..08f9aac66789 100755
--- a/tests/btrfs/056
+++ b/tests/btrfs/056
@@ -39,7 +39,7 @@ test_btrfs_clone_fsync_log_recover()
 	_init_flakey
 	SAVE_MOUNT_OPTIONS="$MOUNT_OPTIONS"
 	MOUNT_OPTIONS="$MOUNT_OPTIONS $2"
-	_mount_flakey
+	_scratch_mount
 
 	BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
@@ -89,10 +89,10 @@ test_btrfs_clone_fsync_log_recover()
 	echo "Verifying file bar2 content"
 	od -t x1 $SCRATCH_MNT/bar2 | _filter_od
 
-	_unmount_flakey
+	_scratch_unmount
 
 	# Verify that there are no consistency errors.
-	_check_scratch_fs $FLAKEY_DEV
+	_check_scratch_fs
 
 	_cleanup_flakey
 	MOUNT_OPTIONS="$SAVE_MOUNT_OPTIONS"
diff --git a/tests/btrfs/085 b/tests/btrfs/085
index 291bb8af0423..8076329c4a59 100755
--- a/tests/btrfs/085
+++ b/tests/btrfs/085
@@ -33,7 +33,7 @@ _require_btrfs_command inspect-internal dump-tree
 has_orphan_item()
 {
 	INO=$1
-	if $BTRFS_UTIL_PROG inspect-internal dump-tree $FLAKEY_DEV | \
+	if $BTRFS_UTIL_PROG inspect-internal dump-tree $SCRATCH_DEV | \
 		grep -q "key (ORPHAN ORPHAN_ITEM $INO)"; then
 		return 0
 	fi
@@ -48,7 +48,7 @@ test_orphan()
 	_scratch_mkfs >> $seqres.full 2>&1
 	_init_flakey
 
-	_mount_flakey
+	_scratch_mount
 
 	$PRECMD
 
@@ -79,13 +79,13 @@ test_orphan()
 	exec 27>&-
 
 	# Orphan item should be on disk if operating correctly
-	_unmount_flakey
+	_scratch_unmount
 	_load_flakey_table $FLAKEY_ALLOW_WRITES
 	if ! has_orphan_item $INO; then
 		echo "ERROR: No orphan item found after umount."
 		return
 	fi
-	_mount_flakey
+	_scratch_mount
 
 	# If $DIR is a subvolume, this will cause a lookup and orphan cleanup
 	(cd $DIR; true)
@@ -94,7 +94,7 @@ test_orphan()
 	# disk until there's a sync.
 	sync
 
-	_unmount_flakey
+	_scratch_unmount
 	if has_orphan_item $INO; then
 		echo "ERROR: Orphan item found after successful mount/sync."
 	fi
@@ -112,8 +112,8 @@ new_default()
 	SUB=$($BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{print $2}')
 	_btrfs subvolume set-default $SUB $SCRATCH_MNT
 
-	_unmount_flakey
-	_mount_flakey
+	_scratch_unmount
+	_scratch_mount
 }
 
 echo "Testing with fs root as default subvolume"
diff --git a/tests/btrfs/095 b/tests/btrfs/095
index de34d64b7b92..6ded7380b912 100755
--- a/tests/btrfs/095
+++ b/tests/btrfs/095
@@ -33,7 +33,7 @@ _require_xfs_io_command "falloc"
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
@@ -127,7 +127,7 @@ _flakey_drop_and_remount
 echo "File contents after log replay:"
 od -t x1 $SCRATCH_MNT/foo | _filter_od
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/btrfs/098 b/tests/btrfs/098
index 6ee0b9101d0f..a8b5cca8b582 100755
--- a/tests/btrfs/098
+++ b/tests/btrfs/098
@@ -28,7 +28,7 @@ _require_cloner
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
 
@@ -89,7 +89,7 @@ echo "File contents after log replay:"
 # the power failure happened.
 od -t x1 $SCRATCH_MNT/foo | _filter_od
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/btrfs/118 b/tests/btrfs/118
index d65398379295..ec6fef2e7922 100755
--- a/tests/btrfs/118
+++ b/tests/btrfs/118
@@ -28,7 +28,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create a snapshot at the root of our filesystem (mount point path), delete it,
 # fsync the mount point path, crash and mount to replay the log. This should
@@ -50,7 +50,7 @@ _flakey_drop_and_remount
 [ -e $SCRATCH_MNT/testdir/snap2 ] && \
 	echo "Snapshot snap2 still exists after log replay"
 
-_unmount_flakey
+_scratch_unmount
 
 echo "Silence is golden"
 
diff --git a/tests/btrfs/119 b/tests/btrfs/119
index a934ad634bf8..1982ae33970e 100755
--- a/tests/btrfs/119
+++ b/tests/btrfs/119
@@ -27,7 +27,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 _btrfs quota enable $SCRATCH_MNT
 
@@ -83,7 +83,7 @@ echo "File digest before after failure:"
 # Must match what he got before the power failure.
 md5sum $SCRATCH_MNT/foobar | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/btrfs/120 b/tests/btrfs/120
index a9b8adecfc9d..efbac5883e10 100755
--- a/tests/btrfs/120
+++ b/tests/btrfs/120
@@ -38,7 +38,7 @@ populate_testdir()
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/testdir
 populate_testdir
@@ -59,6 +59,6 @@ _flakey_drop_and_remount
 echo "Filesystem contents after the second log replay:"
 ls -R $SCRATCH_MNT | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/btrfs/159 b/tests/btrfs/159
index 577652380327..3a9051b1f439 100755
--- a/tests/btrfs/159
+++ b/tests/btrfs/159
@@ -40,7 +40,7 @@ run_test()
 	_scratch_mkfs -O no-holes -n $((64 * 1024)) >>$seqres.full 2>&1
 	_require_metadata_journaling $SCRATCH_DEV
 	_init_flakey
-	_mount_flakey
+	_scratch_mount
 
 	# Create our test file with 832 extents of 256Kb each. Before each
 	# extent, there is a 256Kb hole (except for the first extent, which
@@ -77,7 +77,7 @@ run_test()
 	echo "File digest after power failure and log replay:"
 	md5sum $SCRATCH_MNT/foobar | _filter_scratch
 
-	_unmount_flakey
+	_scratch_unmount
 	_cleanup_flakey
 }
 
diff --git a/tests/btrfs/166 b/tests/btrfs/166
index 719e2a3b6b92..79b8ea0d84c8 100755
--- a/tests/btrfs/166
+++ b/tests/btrfs/166
@@ -28,7 +28,7 @@ _require_dm_target flakey
 _scratch_mkfs  >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Enable qgroups on the filesystem. This will start the qgroup rescan kernel
 # thread.
@@ -39,7 +39,7 @@ _btrfs quota enable $SCRATCH_MNT
 # fail.
 _flakey_drop_and_remount
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 echo "Silence is golden"
diff --git a/tests/btrfs/201 b/tests/btrfs/201
index eb727cd23cd6..50262086fbbe 100755
--- a/tests/btrfs/201
+++ b/tests/btrfs/201
@@ -43,7 +43,7 @@ run_test_leading_hole()
     _scratch_mkfs -O no-holes -n $((64 * 1024)) >>$seqres.full 2>&1
     _require_metadata_journaling $SCRATCH_DEV
     _init_flakey
-    _mount_flakey
+    _scratch_mount
 
     # Create our first file, which is used just to fill space in a leaf. Its
     # items ocuppy most of the first leaf. We use a large xattr since it's an
@@ -86,7 +86,7 @@ run_test_leading_hole()
    echo "File digest after power failure and log replay:"
    md5sum $SCRATCH_MNT/bar | _filter_scratch
 
-   _unmount_flakey
+   _scratch_unmount
    _cleanup_flakey
 }
 
@@ -105,7 +105,7 @@ run_test_middle_hole()
     _scratch_mkfs -O no-holes -n $((64 * 1024)) >>$seqres.full 2>&1
     _require_metadata_journaling $SCRATCH_DEV
     _init_flakey
-    _mount_flakey
+    _scratch_mount
 
     # Create our first file, which is used just to fill space in a leaf. Its
     # items ocuppy most of the first leaf. We use a large xattr since it's an
@@ -150,7 +150,7 @@ run_test_middle_hole()
     echo "File digest after power failure and log replay:"
     md5sum $SCRATCH_MNT/bar | _filter_scratch
 
-    _unmount_flakey
+    _scratch_unmount
     _cleanup_flakey
 }
 
diff --git a/tests/btrfs/209 b/tests/btrfs/209
index 7318f8ae8bcc..bd98b6350159 100755
--- a/tests/btrfs/209
+++ b/tests/btrfs/209
@@ -33,7 +33,7 @@ _require_xfs_io_command "sync_range"
 _scratch_mkfs -O ^no-holes >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create a 256K file with a single extent and fsync it to clear the full sync
 # bit from the inode - we want the msync below to trigger a fast fsync.
@@ -71,7 +71,7 @@ echo "File digest after power failure: $(_md5_checksum $SCRATCH_MNT/foo)"
 # We also want to check that fsck doesn't fail due to an error of a missing
 # file extent item that represents a hole for the range 256K to 512K. The
 # fstests framework does the fsck once the test exits.
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/btrfs/211 b/tests/btrfs/211
index 0127149109c4..38dbadf9f0f3 100755
--- a/tests/btrfs/211
+++ b/tests/btrfs/211
@@ -64,10 +64,10 @@ run_test()
 
     # Unmount the filesystem and run 'btrfs check'/fsck to verify that we don't
     # have a missing hole for the file range from 64K to 128K.
-    _unmount_flakey
-    _check_scratch_fs $FLAKEY_DEV
+    _scratch_unmount
+    _check_scratch_fs
 
-    _mount_flakey
+    _scratch_mount
 
     # Now write to the file range from 0 to 128K. After this we should still have
     # rwo extents in our file, corresponding to the 2 extents we allocated before
@@ -80,23 +80,23 @@ run_test()
 _scratch_mkfs -O ^no-holes >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 echo "Testing without NO_HOLES feature"
 run_test
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 _scratch_mkfs -O no-holes >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 echo
 echo "Testing with the NO_HOLES feature"
 run_test
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/btrfs/231 b/tests/btrfs/231
index d9d0115000e4..5ebb2fdd753d 100755
--- a/tests/btrfs/231
+++ b/tests/btrfs/231
@@ -32,7 +32,7 @@ _require_dm_target flakey
 _scratch_mkfs -O no-holes >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file with 3 extents of 256K and a 256K hole at offset 256K.
 # The file has a size of 1280K.
@@ -73,6 +73,6 @@ _flakey_drop_and_remount
 echo "File data after power failure:"
 od -A d -t x1 $SCRATCH_MNT/foobar
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/btrfs/233 b/tests/btrfs/233
index 6c7cdc9a7040..2966566242e1 100755
--- a/tests/btrfs/233
+++ b/tests/btrfs/233
@@ -30,7 +30,7 @@ _require_btrfs_command inspect-internal dump-tree
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 check_subvol_orphan_item_exists()
 {
@@ -84,7 +84,7 @@ create_subvol_with_orphan()
 	# RW mount.
 	_load_flakey_table $FLAKEY_DROP_WRITES
 	exec 73>&-
-	_unmount_flakey
+	_scratch_unmount
 
 	check_subvol_orphan_item_exists
 	check_subvol_btree_exists
@@ -99,9 +99,9 @@ create_subvol_with_orphan
 # Use a commit interval lower than the default (30 seconds) so that the test
 # is faster and we spend less time waiting for transaction commits.
 MOUNT_OPTIONS="-o commit=1"
-_mount_flakey
+_scratch_mount
 $BTRFS_UTIL_PROG subvolume sync $SCRATCH_MNT >>$seqres.full
-_unmount_flakey
+_scratch_unmount
 
 check_subvol_orphan_item_not_exists
 check_subvol_btree_not_exists
@@ -110,15 +110,15 @@ check_subvol_btree_not_exists
 _cleanup_flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 create_subvol_with_orphan
 MOUNT_OPTIONS="-o ro,commit=1"
-_mount_flakey
+_scratch_mount
 # The subvolume path should not be accessible anymore, even if deletion of the
 # subvolume btree did not happen yet.
 [ -e $SCRATCH_MNT/testsv ] && echo "subvolume path still exists"
-_unmount_flakey
+_scratch_unmount
 
 # The subvolume btree should still exist, even though the path is not accessible.
 check_subvol_btree_exists
@@ -127,15 +127,15 @@ check_subvol_btree_exists
 check_subvol_orphan_item_exists
 
 # Mount the filesystem RO again.
-_mount_flakey
+_scratch_mount
 
 # Now remount RW, then unmount and then check the subvolume's orphan item, btree
 # and path don't exist anymore.
 MOUNT_OPTIONS="-o remount,rw"
-_mount_flakey
+_scratch_mount
 $BTRFS_UTIL_PROG subvolume sync $SCRATCH_MNT >>$seqres.full
 [ -e $SCRATCH_MNT/testsv ] && echo "subvolume path still exists"
-_unmount_flakey
+_scratch_unmount
 
 check_subvol_orphan_item_not_exists
 check_subvol_btree_not_exists
diff --git a/tests/btrfs/236 b/tests/btrfs/236
index a3b58f0cd636..fd2fea85df44 100755
--- a/tests/btrfs/236
+++ b/tests/btrfs/236
@@ -157,7 +157,7 @@ _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 MOUNT_OPTIONS="-o datacow"
-_mount_flakey
+_scratch_mount
 
 # Test a few times each scenario because this test was motivated by a race
 # condition.
@@ -170,12 +170,12 @@ for ((i = 1; i <= 3; i++)); do
 	test_fsync "link_cow_$i" "link"
 done
 
-_unmount_flakey
+_scratch_unmount
 
 # Now lets test with nodatacow.
 if ! _scratch_btrfs_is_zoned; then
 	MOUNT_OPTIONS="-o nodatacow"
-	_mount_flakey
+	_scratch_mount
 
 	echo "Testing fsync after rename with NOCOW writes"
 	for ((i = 1; i <= 3; i++)); do
@@ -186,7 +186,7 @@ if ! _scratch_btrfs_is_zoned; then
 		test_fsync "link_nocow_$i" "link"
 	done
 
-	_unmount_flakey
+	_scratch_unmount
 else
 	# Fake result. Zoned btrfs does not support NOCOW
 	echo "Testing fsync after rename with NOCOW writes"
diff --git a/tests/btrfs/239 b/tests/btrfs/239
index 3ac490273e66..834785fa980f 100755
--- a/tests/btrfs/239
+++ b/tests/btrfs/239
@@ -38,7 +38,7 @@ _require_dm_target flakey
 _scratch_mkfs "-n 65536" >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # "testdir" is inode 257.
 mkdir $SCRATCH_MNT/testdir
@@ -195,7 +195,7 @@ _flakey_drop_and_remount
 echo "File $SCRATCH_MNT/testdir/file1 data:" | _filter_scratch
 od -A d -t x1 $SCRATCH_MNT/testdir/file1
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/btrfs/240 b/tests/btrfs/240
index 6ad7adc11f1e..c9d7cbb35405 100755
--- a/tests/btrfs/240
+++ b/tests/btrfs/240
@@ -31,7 +31,7 @@ _require_xfs_io_command "falloc"
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file with 2 preallocated extents. Leave a 1M hole between them
 # to ensure that we get two file extent items that will never be merged into a
@@ -157,7 +157,7 @@ _flakey_drop_and_remount
 echo "File content before after failure:"
 od -A d -t x1 $SCRATCH_MNT/foobar
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/btrfs/243 b/tests/btrfs/243
index 6e0649fbcf2c..46f3066ef34b 100755
--- a/tests/btrfs/243
+++ b/tests/btrfs/243
@@ -31,7 +31,7 @@ rm -f $seqres.full
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test files.
 touch $SCRATCH_MNT/foo
@@ -82,7 +82,7 @@ od -A d -t x1 $SCRATCH_MNT/bar2
 [ -f $SCRATCH_MNT/foo2 ] || echo "File name foo2 does not exists"
 [ -f $SCRATCH_MNT/foo ] && echo "File name foo still exists"
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 status=0
diff --git a/tests/generic/034 b/tests/generic/034
index cd22f330d77c..45fd234487a1 100755
--- a/tests/generic/034
+++ b/tests/generic/034
@@ -32,7 +32,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/test_dir
 touch $SCRATCH_MNT/test_dir/foo
@@ -66,7 +66,7 @@ rm -f $SCRATCH_MNT/test_dir/bar
 rmdir $SCRATCH_MNT/test_dir
 [ -d $SCRATCH_MNT/test_dir ] && echo "rmdir didn't succeed"
 
-_unmount_flakey
+_scratch_unmount
 
 echo "Silence is golden"
 
diff --git a/tests/generic/039 b/tests/generic/039
index 00d4e4afb5fc..264708543197 100755
--- a/tests/generic/039
+++ b/tests/generic/039
@@ -36,7 +36,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create a test file with 2 hard links in the same directory.
 mkdir -p $SCRATCH_MNT/a/b
diff --git a/tests/generic/040 b/tests/generic/040
index 8b4e3b703a4e..acc3689aa697 100755
--- a/tests/generic/040
+++ b/tests/generic/040
@@ -49,7 +49,7 @@ fi
 
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create a test file with 3001 hard links. This number is large enough to
 # make btrfs start using extrefs at some point even if the fs has the maximum
diff --git a/tests/generic/041 b/tests/generic/041
index 6d42d1a28310..79612397e590 100755
--- a/tests/generic/041
+++ b/tests/generic/041
@@ -53,7 +53,7 @@ fi
 
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create a test file with 3001 hard links. This number is large enough to
 # make btrfs start using extrefs at some point even if the fs has the maximum
diff --git a/tests/generic/056 b/tests/generic/056
index 3e139e1ea48c..20302622dc05 100755
--- a/tests/generic/056
+++ b/tests/generic/056
@@ -34,7 +34,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create one file with data and fsync it.
 # This made the btrfs fsync log persist the data and the inode metadata with
diff --git a/tests/generic/057 b/tests/generic/057
index c5db80977b4d..302231793674 100755
--- a/tests/generic/057
+++ b/tests/generic/057
@@ -34,7 +34,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file with some data.
 $XFS_IO_PROG -f -c "pwrite -S 0xaa -b 8K 0 8K" \
diff --git a/tests/generic/059 b/tests/generic/059
index db48de378600..6420915789f1 100755
--- a/tests/generic/059
+++ b/tests/generic/059
@@ -42,7 +42,7 @@ _require_xfs_io_command "fpunch"
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file.
 $XFS_IO_PROG -f -c "pwrite -S 0x22 -b 16K 0 16K" \
diff --git a/tests/generic/065 b/tests/generic/065
index f7e1e276f5a4..62fd96282b40 100755
--- a/tests/generic/065
+++ b/tests/generic/065
@@ -35,7 +35,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our main test file and directory.
 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 8K" $SCRATCH_MNT/foo | _filter_xfs_io
diff --git a/tests/generic/066 b/tests/generic/066
index 9e4047a11680..98674cdff854 100755
--- a/tests/generic/066
+++ b/tests/generic/066
@@ -40,7 +40,7 @@ _require_attrs
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create out test file and add 3 xattrs to it.
 touch $SCRATCH_MNT/foobar
@@ -89,7 +89,7 @@ _flakey_drop_and_remount
 echo "xattr names and values after second fsync log replay:"
 _getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/073 b/tests/generic/073
index 05df1ea87dce..3e31a0284aa2 100755
--- a/tests/generic/073
+++ b/tests/generic/073
@@ -34,7 +34,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our main test file 'foo', the one we check for data loss.
 # By doing an fsync against our file, it makes btrfs clear the 'needs_full_sync'
diff --git a/tests/generic/090 b/tests/generic/090
index b1ea27bbd287..00cc38fab7d6 100755
--- a/tests/generic/090
+++ b/tests/generic/090
@@ -33,7 +33,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create the test file with some initial data and then fsync it.
 # The fsync here is only needed to trigger the issue in btrfs, as it causes the
diff --git a/tests/generic/101 b/tests/generic/101
index 4295f080130d..316602777eb0 100755
--- a/tests/generic/101
+++ b/tests/generic/101
@@ -40,7 +40,7 @@ fi
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test files and make sure everything is durably persisted.
 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 64K"         \
diff --git a/tests/generic/104 b/tests/generic/104
index 9af3b5582e96..f515e74ecad8 100755
--- a/tests/generic/104
+++ b/tests/generic/104
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directory and files.
 mkdir $SCRATCH_MNT/testdir
@@ -58,7 +58,7 @@ echo "Link count for file bar: $(stat -c %h $SCRATCH_MNT/testdir/bar)"
 rm -f $SCRATCH_MNT/testdir/*
 rmdir $SCRATCH_MNT/testdir
 
-_unmount_flakey
+_scratch_unmount
 
 # The fstests framework will call fsck against our filesystem which will verify
 # that all metadata is in a consistent state.
diff --git a/tests/generic/106 b/tests/generic/106
index 8bcc7575e1f6..5705787c05af 100755
--- a/tests/generic/106
+++ b/tests/generic/106
@@ -29,7 +29,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file with 2 hard links.
 mkdir $SCRATCH_MNT/testdir
@@ -56,7 +56,7 @@ ls -1 $SCRATCH_MNT/testdir
 rm -f $SCRATCH_MNT/testdir/*
 rmdir $SCRATCH_MNT/testdir
 
-_unmount_flakey
+_scratch_unmount
 
 # The fstests framework will call fsck against our filesystem which will verify
 # that all metadata is in a consistent state.
diff --git a/tests/generic/107 b/tests/generic/107
index 8a82d146880d..79f95f9aa533 100755
--- a/tests/generic/107
+++ b/tests/generic/107
@@ -32,7 +32,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directory and file.
 mkdir $SCRATCH_MNT/testdir
@@ -61,7 +61,7 @@ ls -1 $SCRATCH_MNT/testdir
 rm -f $SCRATCH_MNT/testdir/*
 rmdir $SCRATCH_MNT/testdir
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/177 b/tests/generic/177
index 7a4fc77627e8..c4cde443d676 100755
--- a/tests/generic/177
+++ b/tests/generic/177
@@ -34,7 +34,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 
@@ -77,7 +77,7 @@ echo "Fiemap after log replay:"
 # Must match the same extent listing we got before the power failure.
 $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar | _filter_fiemap $BLOCK_SIZE
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/311 b/tests/generic/311
index 5d21752fe864..a946b96bd77c 100755
--- a/tests/generic/311
+++ b/tests/generic/311
@@ -56,19 +56,19 @@ _run_test()
 
 	_md5_checksum $testfile
 	_load_flakey_table $FLAKEY_DROP_WRITES $lockfs
-	_unmount_flakey
+	_scratch_unmount
 
 	#Ok mount so that any recovery that needs to happen is done
 	_load_flakey_table $FLAKEY_ALLOW_WRITES
-	_mount_flakey
+	_scratch_mount
 	_md5_checksum $testfile
 
 	#Unmount and fsck to make sure we got a valid fs after replay
-	_unmount_flakey
-	_check_scratch_fs $FLAKEY_DEV
+	_scratch_unmount
+	_check_scratch_fs
 	[ $? -ne 0 ] && _fatal "fsck failed"
 
-	_mount_flakey
+	_scratch_mount
 }
 
 _scratch_mkfs >> $seqres.full 2>&1
@@ -76,7 +76,7 @@ _require_metadata_journaling $SCRATCH_DEV
 
 # Create a basic flakey device that will never error out
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 buffered=0
 direct=1
diff --git a/tests/generic/321 b/tests/generic/321
index df8f13597702..51f509e5aa88 100755
--- a/tests/generic/321
+++ b/tests/generic/321
@@ -26,24 +26,24 @@ _require_dm_target flakey
 
 _clean_working_dir()
 {
-	_mount_flakey
+	_scratch_mount
 	rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
-	_unmount_flakey
+	_scratch_unmount
 }
 
 # Btrfs wasn't making sure the directory survived fsync
 _directory_test()
 {
 	echo "fsync new directory"
-	_mount_flakey
+	_scratch_mount
 	mkdir $SCRATCH_MNT/bar
 	$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
 
 	_flakey_drop_and_remount
 
 	_ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
-	_unmount_flakey
-	_check_scratch_fs $FLAKEY_DEV
+	_scratch_unmount
+	_check_scratch_fs
 	[ $? -ne 0 ] && _fatal "fsck failed"
 }
 
@@ -51,7 +51,7 @@ _directory_test()
 _rename_test()
 {
 	echo "rename fsync test"
-	_mount_flakey
+	_scratch_mount
 	touch $SCRATCH_MNT/foo
 	mkdir $SCRATCH_MNT/bar
 	$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
@@ -63,8 +63,8 @@ _rename_test()
 
 	_ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
 	_ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
-	_unmount_flakey
-	_check_scratch_fs $FLAKEY_DEV
+	_scratch_unmount
+	_check_scratch_fs
 	[ $? -ne 0 ] && _fatal "fsck failed"
 }
 
@@ -73,7 +73,7 @@ _rename_test()
 _replay_rename_test()
 {
 	echo "replay rename fsync test"
-	_mount_flakey
+	_scratch_mount
 	touch $SCRATCH_MNT/foo
 	mkdir $SCRATCH_MNT/bar
 	$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
@@ -90,7 +90,7 @@ _replay_rename_test()
 
 	_ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
 	_ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
-	_unmount_flakey
+	_scratch_unmount
 }
 
 _scratch_mkfs >> $seqres.full 2>&1
diff --git a/tests/generic/322 b/tests/generic/322
index 5cb77cbfab12..d66a30ffafdc 100755
--- a/tests/generic/322
+++ b/tests/generic/322
@@ -24,16 +24,16 @@ _require_dm_target flakey
 
 _clean_working_dir()
 {
-	_mount_flakey
+	_scratch_mount
 	rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
-	_unmount_flakey
+	_scratch_unmount
 }
 
 # Btrfs wasn't making sure the new file after rename survived the fsync
 _rename_test()
 {
 	echo "fsync rename test"
-	_mount_flakey
+	_scratch_mount
 	$XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" $SCRATCH_MNT/foo \
 		>> $seqres.full 2>&1
 	mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar
@@ -43,8 +43,8 @@ _rename_test()
 	_flakey_drop_and_remount
 
 	md5sum $SCRATCH_MNT/bar | _filter_scratch
-	_unmount_flakey
-	_check_scratch_fs $FLAKEY_DEV
+	_scratch_unmount
+	_check_scratch_fs
 	[ $? -ne 0 ] && _fatal "fsck failed"
 }
 
@@ -53,7 +53,7 @@ _rename_test()
 _write_after_fsync_rename_test()
 {
 	echo "fsync rename test"
-	_mount_flakey
+	_scratch_mount
 	$XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" -c "pwrite 2M 1M" \
 		-c "sync_range -b 2M 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1
 	mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar
@@ -63,7 +63,7 @@ _write_after_fsync_rename_test()
 	_flakey_drop_and_remount
 
 	md5sum $SCRATCH_MNT/bar | _filter_scratch
-	_unmount_flakey
+	_scratch_unmount
 }
 
 _scratch_mkfs >> $seqres.full 2>&1
diff --git a/tests/generic/325 b/tests/generic/325
index 932c18f17ef4..7c055b6fdb07 100755
--- a/tests/generic/325
+++ b/tests/generic/325
@@ -34,7 +34,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create the file first.
 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 256K" $SCRATCH_MNT/foo | _filter_xfs_io
@@ -69,7 +69,7 @@ _flakey_drop_and_remount
 echo "File content after crash/reboot and fs mount:"
 od -t x1 $SCRATCH_MNT/foo
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/335 b/tests/generic/335
index f287b5150a39..19c8fe3b6a1a 100755
--- a/tests/generic/335
+++ b/tests/generic/335
@@ -29,7 +29,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directories and the file we will later check if it has
 # disappeared.
@@ -73,7 +73,7 @@ echo "Filesystem content after power failure:"
 # Must match what we had before the power failure.
 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/336 b/tests/generic/336
index c874997e420b..304ff574440c 100755
--- a/tests/generic/336
+++ b/tests/generic/336
@@ -36,7 +36,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directories and the file we will later check if it has
 # disappeared (file bar).
@@ -70,7 +70,7 @@ echo "Filesystem content after power failure:"
 # Must match what we had before the power failure.
 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/b $SCRATCH_MNT/c | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/341 b/tests/generic/341
index 80fdcbac7a43..aa41dbac5292 100755
--- a/tests/generic/341
+++ b/tests/generic/341
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir -p $SCRATCH_MNT/a/x
 $XFS_IO_PROG -f -c "pwrite -S 0xaf 0 32K" $SCRATCH_MNT/a/x/foo | _filter_xfs_io
@@ -62,6 +62,6 @@ echo "File digests after log replay:"
 md5sum $SCRATCH_MNT/a/y/foo | _filter_scratch
 md5sum $SCRATCH_MNT/a/y/bar | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/342 b/tests/generic/342
index a7aca860b9a8..01d01226d1dc 100755
--- a/tests/generic/342
+++ b/tests/generic/342
@@ -35,7 +35,7 @@ if [ $FSTYP = "f2fs" ]; then
 fi
 
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/a
 $XFS_IO_PROG -f -c "pwrite -S 0xf1 0 16K" $SCRATCH_MNT/a/foo | _filter_xfs_io
@@ -64,6 +64,6 @@ echo "File digests after log replay:"
 md5sum $SCRATCH_MNT/a/foo | _filter_scratch
 md5sum $SCRATCH_MNT/a/bar | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/343 b/tests/generic/343
index 97ff4f984258..5fff62895089 100755
--- a/tests/generic/343
+++ b/tests/generic/343
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directories and files.
 mkdir $SCRATCH_MNT/x
@@ -56,6 +56,6 @@ _flakey_drop_and_remount
 echo "Filesystem contents after log replay:"
 ls -R $SCRATCH_MNT/x $SCRATCH_MNT/y | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/348 b/tests/generic/348
index 1905a6e6a7ea..52404b4df556 100755
--- a/tests/generic/348
+++ b/tests/generic/348
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/testdir1
 # Make sure it's durably persisted.
@@ -54,6 +54,6 @@ echo "Symlink contents after log replay:"
 readlink $SCRATCH_MNT/testdir1/bar1 | _filter_scratch
 readlink $SCRATCH_MNT/testdir2/bar2 | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/376 b/tests/generic/376
index 17a5f290bed6..390a07dddbbf 100755
--- a/tests/generic/376
+++ b/tests/generic/376
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directories and files.
 mkdir $SCRATCH_MNT/dir
@@ -46,6 +46,6 @@ _flakey_drop_and_remount
 echo "Filesystem contents after log replay:"
 ls -R $SCRATCH_MNT/dir | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/456 b/tests/generic/456
index 32afa398f11c..0f0830d2a296 100755
--- a/tests/generic/456
+++ b/tests/generic/456
@@ -40,7 +40,7 @@ _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # See this post for reverse engineering of this auto generated test:
 # https://marc.info/?l=linux-ext4&m=151137380830381&w=2
@@ -56,7 +56,7 @@ EOF
 run_check $FSX_PROG -d --replay-ops $fsxops $SCRATCH_MNT/testfile
 
 _flakey_drop_and_remount
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 _check_scratch_fs
 
diff --git a/tests/generic/479 b/tests/generic/479
index 650c921b8fdc..f966100124dd 100755
--- a/tests/generic/479
+++ b/tests/generic/479
@@ -36,7 +36,7 @@ run_test()
 	_scratch_mkfs >>$seqres.full 2>&1
 	_require_metadata_journaling $SCRATCH_DEV
 	_init_flakey
-	_mount_flakey
+	_scratch_mount
 
 	mkdir $SCRATCH_MNT/testdir
 	case $file_type in
@@ -75,7 +75,7 @@ run_test()
 	# replaying the fsync log/journal succeeds, that is the mount operation
 	# does not fail.
 	_flakey_drop_and_remount
-	_unmount_flakey
+	_scratch_unmount
 	_cleanup_flakey
 }
 
diff --git a/tests/generic/480 b/tests/generic/480
index 6c599446b5e5..1ed3b21a657f 100755
--- a/tests/generic/480
+++ b/tests/generic/480
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/testdir
 touch $SCRATCH_MNT/testdir/foo
@@ -50,7 +50,7 @@ $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
 # the fsync log/journal succeeds, that is the mount operation does not fail.
 _flakey_drop_and_remount
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 echo "Silence is golden"
diff --git a/tests/generic/481 b/tests/generic/481
index 5c980cf01d60..ecc1705bbe60 100755
--- a/tests/generic/481
+++ b/tests/generic/481
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # create a file and keep it in write ahead log
 $XFS_IO_PROG -f -c "fsync" $SCRATCH_MNT/foo
@@ -42,7 +42,7 @@ _flakey_drop_and_remount
 # see if we can create a new file successfully
 touch $SCRATCH_MNT/bar
 
-_unmount_flakey
+_scratch_unmount
 
 echo "Silence is golden"
 
diff --git a/tests/generic/483 b/tests/generic/483
index a71f96ad0dc1..01871d63a43e 100755
--- a/tests/generic/483
+++ b/tests/generic/483
@@ -31,7 +31,7 @@ _require_xfs_io_command "fiemap"
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # The fiemap results in the golden output requires file allocations to align to
 # 256K boundaries.
@@ -95,7 +95,7 @@ $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/baz | _filter_hole_fiemap
 echo "File baz size:"
 stat --format %s $SCRATCH_MNT/baz
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 status=0
diff --git a/tests/generic/489 b/tests/generic/489
index e76055fa4436..05e69897e2b6 100755
--- a/tests/generic/489
+++ b/tests/generic/489
@@ -30,7 +30,7 @@ _require_attrs
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 touch $SCRATCH_MNT/foobar
 $SETFATTR_PROG -n user.xa1 -v qwerty $SCRATCH_MNT/foobar
@@ -53,7 +53,7 @@ _getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
 echo "File data after power failure:"
 od -t x1 $SCRATCH_MNT/foobar
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 status=0
diff --git a/tests/generic/498 b/tests/generic/498
index f58c9ed510e8..b0bf403add15 100755
--- a/tests/generic/498
+++ b/tests/generic/498
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/A
 mkdir $SCRATCH_MNT/B
@@ -49,7 +49,7 @@ _flakey_drop_and_remount
 [ -d $SCRATCH_MNT/A ] || echo "directory A missing"
 [ -f $SCRATCH_MNT/B/foo ] || echo "file B/foo is missing"
 
-_unmount_flakey
+_scratch_unmount
 
 echo "Silence is golden"
 status=0
diff --git a/tests/generic/501 b/tests/generic/501
index 4444016bc2a6..1cf54fc04e70 100755
--- a/tests/generic/501
+++ b/tests/generic/501
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 _require_congruent_file_oplen $SCRATCH_MNT 2097152
 
 # Use file sizes and offsets/lengths for the clone operation that are multiples
@@ -57,7 +57,7 @@ _flakey_drop_and_remount
 echo "File bar digest after power failure:"
 md5sum $SCRATCH_MNT/bar | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 status=0
diff --git a/tests/generic/502 b/tests/generic/502
index f488bd06c7a8..553b186e5e46 100755
--- a/tests/generic/502
+++ b/tests/generic/502
@@ -38,7 +38,7 @@ if [ $FSTYP = "f2fs" ]; then
 fi
 
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file with 2 hard links in the same parent directory.
 mkdir $SCRATCH_MNT/testdir
@@ -69,7 +69,7 @@ _flakey_drop_and_remount
 echo "Contents of test directory after the power failure:"
 ls -R $SCRATCH_MNT/testdir | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 _cleanup_flakey
 
 status=0
diff --git a/tests/generic/509 b/tests/generic/509
index 5025c0d74164..f38e4503857b 100755
--- a/tests/generic/509
+++ b/tests/generic/509
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our tmpfile, write some data to it and fsync it. We want a power
 # failure to happen after the fsync, so that we have an inode with a link
@@ -43,7 +43,7 @@ $XFS_IO_PROG -T \
 # Simulate a power failure and mount the filesystem to check that it succeeds.
 _flakey_drop_and_remount
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/510 b/tests/generic/510
index abf18f1bfee4..0c3f81f5bf70 100755
--- a/tests/generic/510
+++ b/tests/generic/510
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directories and file.
 mkdir $SCRATCH_MNT/testdir
@@ -56,7 +56,7 @@ _flakey_drop_and_remount
 echo "Filesystem content after power failure:"
 ls -R $SCRATCH_MNT/testdir | _filter_scratch
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/512 b/tests/generic/512
index 8965d9d639fa..f6ed90b70c62 100755
--- a/tests/generic/512
+++ b/tests/generic/512
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 $XFS_IO_PROG -f \
 	     -c "pwrite -S 0xb6 0 21" \
@@ -46,7 +46,7 @@ _flakey_drop_and_remount
 echo "File content after power failure:"
 od -t x1 -A d $SCRATCH_MNT/foobar
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/520 b/tests/generic/520
index f2523fca27f2..3c7ae615affc 100755
--- a/tests/generic/520
+++ b/tests/generic/520
@@ -43,9 +43,9 @@ after=""
 # adds about 10 seconds of delay in total for the 37 tests.
 clean_dir()
 {
-	_mount_flakey
+	_scratch_mount
 	rm -rf $(find $SCRATCH_MNT/* | grep -v "lost+found")
-	_unmount_flakey
+	_scratch_unmount
 }
 
 check_consistency()
@@ -61,8 +61,8 @@ check_consistency()
 		echo "After: $after"
 	fi
 
-	_unmount_flakey
-	_check_scratch_fs $FLAKEY_DEV
+	_scratch_unmount
+	_check_scratch_fs
 }
 
 # create a hard link $2 to file $1, and fsync $3, followed by power-cut
@@ -82,7 +82,7 @@ test_link_fsync()
 
 	echo -ne "\n=== link $src $dest  with fsync $fsync ===\n" | \
 		_filter_scratch
-	_mount_flakey
+	_scratch_mount
 
 	# Now execute the workload
 	# Create the directory in which the source and destination files
@@ -116,7 +116,7 @@ test_link_sync()
 	before=""
 	after=""
 	echo -ne "\n=== link $src $dest  with sync ===\n" | _filter_scratch
-	_mount_flakey
+	_scratch_mount
 
 	# now execute the workload
 	# Create the directory in which the source and destination files
diff --git a/tests/generic/526 b/tests/generic/526
index af77ccaff32b..b820dda3a43c 100755
--- a/tests/generic/526
+++ b/tests/generic/526
@@ -36,7 +36,7 @@ if [ $FSTYP = "f2fs" ]; then
 fi
 
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/testdir
 echo -n "foo" > $SCRATCH_MNT/testdir/fname1
@@ -63,7 +63,7 @@ echo "File fname2 data after power failure: $(cat $SCRATCH_MNT/testdir/fname2)"
 echo "File fname3 data after power failure: $(cat $SCRATCH_MNT/testdir/fname3)"
 echo "File fname4 data after power failure: $(cat $SCRATCH_MNT/testdir/fname4)"
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/527 b/tests/generic/527
index 90555077f007..e09efff9e2f1 100755
--- a/tests/generic/527
+++ b/tests/generic/527
@@ -36,7 +36,7 @@ if [ $FSTYP = "f2fs" ]; then
 fi
 
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/testdir
 echo -n "foo" > $SCRATCH_MNT/testdir/fname1
@@ -88,7 +88,7 @@ echo "File a2 data after power failure: $(cat $SCRATCH_MNT/testdir2/a2)"
 echo "File zz data after power failure: $(cat $SCRATCH_MNT/testdir2/zz)"
 echo "File zz_link data after power failure: $(cat $SCRATCH_MNT/testdir2/zz_link)"
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/534 b/tests/generic/534
index f1cd90c0ec75..5c68ebde4c2b 100755
--- a/tests/generic/534
+++ b/tests/generic/534
@@ -28,7 +28,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file with an initial size of 8000 bytes, then fsync it,
 # followed by a truncate that reduces its size down to 3000 bytes.
@@ -51,7 +51,7 @@ _flakey_drop_and_remount
 echo "File content after power failure:"
 od -A d -t x1 $SCRATCH_MNT/bar
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/535 b/tests/generic/535
index 98e2f2384a64..9f552ee8a7c7 100755
--- a/tests/generic/535
+++ b/tests/generic/535
@@ -48,7 +48,7 @@ do_check()
 	local target=$1
 	local is_dir=$2
 
-	_mount_flakey
+	_scratch_mount
 
 	if [ $is_dir = 1 ]; then
 		mkdir $target
@@ -81,7 +81,7 @@ do_check()
 	else
 		rm -f $target
 	fi
-	_unmount_flakey
+	_scratch_unmount
 }
 
 echo "Silence is golden"
diff --git a/tests/generic/546 b/tests/generic/546
index ab4ea657ee00..3fb705c0226f 100755
--- a/tests/generic/546
+++ b/tests/generic/546
@@ -36,7 +36,7 @@ _require_dm_target flakey
 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 _require_congruent_file_oplen $SCRATCH_MNT 4096
 
 # Create preallocated extent where we can write into
diff --git a/tests/generic/547 b/tests/generic/547
index 14d02b4fdc8e..880dfecb64b4 100755
--- a/tests/generic/547
+++ b/tests/generic/547
@@ -36,7 +36,7 @@ mkdir $fssum_files_dir
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/test
 args=`_scale_fsstress_args -p 4 -n 100 -d $SCRATCH_MNT/test`
@@ -59,7 +59,7 @@ _flakey_drop_and_remount
 # must match.
 $FSSUM_PROG -r $fssum_files_dir/fs_digest $SCRATCH_MNT/test
 
-_unmount_flakey
+_scratch_unmount
 
 status=0
 exit
diff --git a/tests/generic/552 b/tests/generic/552
index 9f3d7fdebddc..2f38141686cd 100755
--- a/tests/generic/552
+++ b/tests/generic/552
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directory with two files in it.
 mkdir $SCRATCH_MNT/dir
@@ -84,6 +84,6 @@ _flakey_drop_and_remount
 echo "File data after power failure:"
 od -t x1 -A d $SCRATCH_MNT/dir/baz
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/557 b/tests/generic/557
index 742180e2b7ea..00a4c2525035 100755
--- a/tests/generic/557
+++ b/tests/generic/557
@@ -28,7 +28,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directory with one file in it and fsync the file.
 mkdir $SCRATCH_MNT/dir
@@ -64,7 +64,7 @@ _flakey_drop_and_remount
 
 [ -f $SCRATCH_MNT/dir/foo ] && echo "File foo still exists"
 
-_unmount_flakey
+_scratch_unmount
 echo "Silence is golden"
 status=0
 exit
diff --git a/tests/generic/588 b/tests/generic/588
index 0ee9f001c959..90491bde2c26 100755
--- a/tests/generic/588
+++ b/tests/generic/588
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 _require_congruent_file_oplen $SCRATCH_MNT 65536
 
@@ -65,6 +65,6 @@ _flakey_drop_and_remount
 echo "File digest after mount:"
 _md5_checksum $SCRATCH_MNT/foobar
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/640 b/tests/generic/640
index c3b33746e669..2aa859060ed7 100755
--- a/tests/generic/640
+++ b/tests/generic/640
@@ -30,7 +30,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create two test directories, one with a file we will rename later.
 mkdir $SCRATCH_MNT/A
@@ -94,6 +94,6 @@ fi
 [ -f $SCRATCH_MNT/A/bar ] || echo "File A/bar is missing"
 [ -f $SCRATCH_MNT/baz ] || echo "File baz is missing"
 
-_unmount_flakey
+_scratch_unmount
 status=0
 exit
diff --git a/tests/generic/677 b/tests/generic/677
index 86099454ff39..176c56c0e5b0 100755
--- a/tests/generic/677
+++ b/tests/generic/677
@@ -34,7 +34,7 @@ rm -f $seqres.full
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # The fiemap results in the golden output requires file allocations to align to
 # 1MB boundaries.
@@ -80,7 +80,7 @@ _flakey_drop_and_remount
 echo "List of extents after power failure:"
 $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foo | _filter_fiemap
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 status=0
diff --git a/tests/generic/690 b/tests/generic/690
index ef5bd1983cef..8e01411bc0c3 100755
--- a/tests/generic/690
+++ b/tests/generic/690
@@ -46,7 +46,7 @@ fi
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test directory.
 mkdir "$SCRATCH_MNT"/testdir
@@ -80,7 +80,7 @@ _flakey_drop_and_remount
 symlink_content=$(readlink "$SCRATCH_MNT"/testdir/baz | _filter_scratch)
 echo "symlink content: ${symlink_content}"
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 status=0
diff --git a/tests/generic/695 b/tests/generic/695
index 694f42454511..78271e7b0970 100755
--- a/tests/generic/695
+++ b/tests/generic/695
@@ -35,7 +35,7 @@ _require_xfs_io_command "fiemap"
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # We punch 2M holes and require extent allocations to align to 2M in fiemap
 # results.
@@ -83,7 +83,7 @@ $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar | _filter_fiemap
 echo "File content after power failure:"
 _hexdump $SCRATCH_MNT/foobar
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 status=0
diff --git a/tests/generic/703 b/tests/generic/703
index 2bace19d6f06..30afe6da711a 100755
--- a/tests/generic/703
+++ b/tests/generic/703
@@ -53,7 +53,7 @@ _require_fio $fio_config
 _scratch_mkfs >>$seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # We do 64K writes in the fio job.
 _require_congruent_file_oplen $SCRATCH_MNT $((64 * 1024))
@@ -94,7 +94,7 @@ if [ "$digest_after" != "$digest_before" ]; then
 	echo "Digest after power failure:  $digest_after"
 fi
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 echo "Silence is golden"
diff --git a/tests/generic/741 b/tests/generic/741
index c15dc4345b7a..9bde8cbdd9b1 100755
--- a/tests/generic/741
+++ b/tests/generic/741
@@ -19,7 +19,7 @@ _cleanup()
 	_unmount $extra_mnt &> /dev/null
 	_unmount $extra_mnt &> /dev/null
 	rm -rf $extra_mnt
-	_unmount_flakey
+	_scratch_unmount
 	_cleanup_flakey
 	cd /
 	rm -r -f $tmp.*
@@ -38,7 +38,7 @@ _require_dm_target flakey
 
 _scratch_mkfs >> $seqres.full
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 extra_mnt=$TEST_DIR/extra_mnt
 rm -rf $extra_mnt
@@ -46,13 +46,13 @@ mkdir -p $extra_mnt
 
 # Mount must fail because the physical device has a dm created on it.
 # Filters alter the return code of the mount.
-_mount $SCRATCH_DEV $extra_mnt 2>&1 | \
-			_filter_testdir_and_scratch | _filter_error_mount
+_mount $NON_FLAKEY_DEV $extra_mnt 2>/dev/null && \
+	_fail "mount of busy device succeeded"
 
-# Try again with flakey unmounted, must fail.
-_unmount_flakey
-_mount $SCRATCH_DEV $extra_mnt 2>&1 | \
-			_filter_testdir_and_scratch | _filter_error_mount
+# Try again with flakey unmounted, must also fail.
+_scratch_unmount
+_mount $NON_FLAKEY_DEV $extra_mnt 2>/dev/null && \
+	_fail "mount of busy device succeeded"
 
 # Removing dm should make mount successful.
 _cleanup_flakey
diff --git a/tests/generic/741.out b/tests/generic/741.out
index b694f5fad6b8..9a6fc96d1c88 100644
--- a/tests/generic/741.out
+++ b/tests/generic/741.out
@@ -1,3 +1 @@
 QA output created by 741
-mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy
-mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy
diff --git a/tests/generic/745 b/tests/generic/745
index 62624b15bc65..09a1860302d2 100755
--- a/tests/generic/745
+++ b/tests/generic/745
@@ -46,7 +46,7 @@ esac
 _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create the test file with some initial data and make sure everything is
 # durably persisted.
diff --git a/tests/generic/764 b/tests/generic/764
index 55937fc0c988..b23f86e501f7 100755
--- a/tests/generic/764
+++ b/tests/generic/764
@@ -30,7 +30,7 @@ _require_test_program "multi_open_unlink"
 _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 mkdir $SCRATCH_MNT/testdir
 $here/src/multi_open_unlink -f $SCRATCH_MNT/testdir/foo -F -S -n 1 -s 0
@@ -43,7 +43,7 @@ _flakey_drop_and_remount
 # more hard links.
 ls $SCRATCH_MNT/testdir
 
-_unmount_flakey
+_scratch_unmount
 
 echo "Silence is golden"
 status=0
diff --git a/tests/generic/771 b/tests/generic/771
index ea3e4ffa13da..1028c6d8c7e1 100755
--- a/tests/generic/771
+++ b/tests/generic/771
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our first test file with some data.
 mkdir $SCRATCH_MNT/testdir
diff --git a/tests/generic/779 b/tests/generic/779
index 842472aedc18..770a2e00b97c 100755
--- a/tests/generic/779
+++ b/tests/generic/779
@@ -32,7 +32,7 @@ rm -f $seqres.full
 _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test dir and add a symlink inside it.
 mkdir $SCRATCH_MNT/dir
@@ -54,7 +54,7 @@ _flakey_drop_and_remount
 [ -L $SCRATCH_MNT/dir/new-slink ] || echo "symlink dir/new-slink not found"
 echo "symlink content: $(readlink $SCRATCH_MNT/dir/new-slink)"
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 _exit 0
diff --git a/tests/generic/782 b/tests/generic/782
index 13c729d29bc4..710fca701cbd 100755
--- a/tests/generic/782
+++ b/tests/generic/782
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our test file.
 touch $SCRATCH_MNT/foo
@@ -68,6 +68,6 @@ ls -1 $SCRATCH_MNT | grep -v 'lost+found'
 echo "File data:"
 _hexdump $SCRATCH_MNT/foo
 
-_unmount_flakey
+_scratch_unmount
 
 _exit 0
diff --git a/tests/generic/784 b/tests/generic/784
index 8e01dff05957..5d972ccef178 100755
--- a/tests/generic/784
+++ b/tests/generic/784
@@ -31,7 +31,7 @@ _require_dm_target flakey
 _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 list_fs_contents()
 {
@@ -70,7 +70,7 @@ _flakey_drop_and_remount
 echo -e "\nfs contents after power failure:\n"
 list_fs_contents
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 _exit 0
diff --git a/tests/generic/785 b/tests/generic/785
index a6cfdd87f31b..d918de4fcda9 100755
--- a/tests/generic/785
+++ b/tests/generic/785
@@ -33,7 +33,7 @@ _require_fssum
 _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 # Create our first test file.
 echo -n > $SCRATCH_MNT/file1
@@ -67,7 +67,7 @@ _flakey_drop_and_remount
 # failure and after the last fsync.
 $FSSUM_PROG -r $tmp.fssum $SCRATCH_MNT/
 
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 _exit 0
diff --git a/tests/xfs/051 b/tests/xfs/051
index ddc28ac9719f..95c89bbab47e 100755
--- a/tests/xfs/051
+++ b/tests/xfs/051
@@ -41,9 +41,9 @@ _kill_fsstress
 _scratch_unmount
 
 # Initialize a dm-flakey device that will pass I/Os for 5s and fail thereafter.
-_init_flakey
 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
 FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 5 180"
+_init_flakey
 _load_flakey_table $FLAKEY_ALLOW_WRITES
 
 # Set a 10s log recovery delay and mount the flakey device. This should allow
@@ -54,7 +54,7 @@ echo 10 > /sys/fs/xfs/debug/log_recovery_delay
 
 # The mount should fail due to dm-flakey. Note that this is dangerous on kernels
 # without the xfs_buf log recovery race fixes.
-_mount_flakey > /dev/null 2>&1
+_scratch_mount > /dev/null 2>&1
 
 echo 0 > /sys/fs/xfs/debug/log_recovery_delay
 
diff --git a/tests/xfs/438 b/tests/xfs/438
index 6d1988c8b9b8..4ff249df6967 100755
--- a/tests/xfs/438
+++ b/tests/xfs/438
@@ -32,7 +32,7 @@ _cleanup()
 		sysctl -w fs.xfs.xfssyncd_centisecs=${interval} >/dev/null 2>&1
 	cd /
 	rm -f $tmp.*
-	_unmount_flakey >/dev/null 2>&1
+	_scratch_unmount >/dev/null 2>&1
 	_cleanup_flakey > /dev/null 2>&1
 }
 
@@ -100,6 +100,9 @@ echo "Silence is golden"
 
 _scratch_mkfs > $seqres.full 2>&1
 
+# this needs to happen after mkfs, but before _init_flakey overrides SCRATCH_DEV
+FLAKEY_TABLE_ERROR=$(make_xfs_scratch_flakey_table)
+
 # no error will be injected
 _init_flakey
 $DMSETUP_PROG info >> $seqres.full
@@ -111,7 +114,7 @@ interval=$(sysctl -n fs.xfs.xfssyncd_centisecs 2>/dev/null)
 sysctl -w fs.xfs.xfssyncd_centisecs=100 >> $seqres.full 2>&1
 
 _qmount_option "usrquota"
-_mount_flakey
+_scratch_mount
 
 # We need to set the quota limitation twice, and inject the write error
 # after the second setting. If we try to inject the write error after
@@ -127,7 +130,6 @@ xfs_freeze -f $SCRATCH_MNT
 xfs_freeze -u $SCRATCH_MNT
 
 # inject write IO error
-FLAKEY_TABLE_ERROR=$(make_xfs_scratch_flakey_table)
 _load_flakey_table ${FLAKEY_ERROR_WRITES}
 $DMSETUP_PROG info >> $seqres.full
 $DMSETUP_PROG table >> $seqres.full
@@ -142,7 +144,7 @@ _scratch_sync
 # the completion of the retried write of dquota buffer
 sleep 2
 
-_unmount_flakey
+_scratch_unmount
 
 _cleanup_flakey
 
diff --git a/tests/xfs/542 b/tests/xfs/542
index 09200c00501a..565dc450a3b7 100755
--- a/tests/xfs/542
+++ b/tests/xfs/542
@@ -34,7 +34,7 @@ _require_flakey_with_error_writes
 
 _scratch_mkfs >> $seqres.full
 _init_flakey
-_mount_flakey
+_scratch_mount
 
 blksz=$(_get_file_block_size $SCRATCH_MNT)
 
@@ -61,7 +61,7 @@ _load_flakey_table $FLAKEY_ALLOW_WRITES
 # Try a post-fail reflink and then unmount. Both of these are known to produce
 # errors and/or assert failures on XFS if we trip over a stale delalloc block.
 _cp_reflink $SCRATCH_MNT/file2 $SCRATCH_MNT/file3
-_unmount_flakey
+_scratch_unmount
 
 # success, all done
 status=0
diff --git a/tests/xfs/605 b/tests/xfs/605
index b31fe6b0a316..576cee4035ab 100755
--- a/tests/xfs/605
+++ b/tests/xfs/605
@@ -41,7 +41,7 @@ _scratch_mkfs >> $seqres.full 2>&1
 echo "Initialize and mount filesystem on flakey device"
 _init_flakey
 _load_flakey_table $FLAKEY_ALLOW_WRITES
-_mount_flakey
+_scratch_mount
 
 echo "Create test file"
 $XFS_IO_PROG -s -f -c "pwrite 0 5M" $testfile >> $seqres.full
@@ -50,10 +50,10 @@ echo "Punch alternative blocks of test file"
 $here/src/punch-alternating $testfile
 
 echo "Mount cycle the filesystem on flakey device"
-_unmount_flakey
-_mount_flakey
+_scratch_unmount
+_scratch_mount
 
-device=$(readlink -f $FLAKEY_DEV)
+device=$(readlink -f $SCRATCH_DEV)
 device=$(_short_dev $device)
 
 echo "Pin log items in the AIL"
@@ -73,7 +73,7 @@ echo "Unpin log items in AIL"
 echo 0 > /sys/fs/xfs/${device}/errortag/log_item_pin
 
 echo "Unmount filesystem on flakey device"
-_unmount_flakey
+_scratch_unmount
 
 echo "Clean up flakey device"
 _cleanup_flakey
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 02/12] ext4/006: call e2fsck directly
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
  2025-12-10  5:46 ` [PATCH 01/12] dmflakey: override SCRATCH_DEV in _init_flakey Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 19:32   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 03/12] common: add a _check_dev_fs helper Christoph Hellwig
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

_check_scratch_fs takes an optional device name, but no optional
arguments.  Call e2fsck directly for this extN-specific test instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/ext4/006 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/ext4/006 b/tests/ext4/006
index 2ece22a4bd1e..07dcf356b0bc 100755
--- a/tests/ext4/006
+++ b/tests/ext4/006
@@ -44,7 +44,7 @@ repair_scratch() {
 	res=$?
 	if [ "${res}" -eq 0 ]; then
 		echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
-		_check_scratch_fs -n >> "${FSCK_LOG}" 2>&1
+		e2fsck -n >> "${FSCK_LOG}" 2>&1
 		res=$?
 	fi
 	echo "++ fsck returns ${res}" >> "${FSCK_LOG}"
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 03/12] common: add a _check_dev_fs helper
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
  2025-12-10  5:46 ` [PATCH 01/12] dmflakey: override SCRATCH_DEV in _init_flakey Christoph Hellwig
  2025-12-10  5:46 ` [PATCH 02/12] ext4/006: call e2fsck directly Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 23:24   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 04/12] ext4/032: use _check_dev_fs Christoph Hellwig
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Add a helper to run the file system checker for a given device, and stop
overloading _check_scratch_fs with the optional device argument that
creates complication around scratch RT and log devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---

Note: dmthin should probably do the same as dmflakey does, but all
my attempts never got the new SCRATCH_DEV value propagated out of
_dmthin_init.  Maybe someone smarted than me wants to give it another
try.

 common/dmthin     |  6 +++++-
 common/rc         | 21 +++++++++++++++++----
 tests/btrfs/176   |  4 ++--
 tests/generic/648 |  2 +-
 tests/xfs/601     |  2 +-
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/common/dmthin b/common/dmthin
index a1e1fb8763c0..3bea828d0375 100644
--- a/common/dmthin
+++ b/common/dmthin
@@ -33,7 +33,11 @@ _dmthin_cleanup()
 _dmthin_check_fs()
 {
 	_unmount $SCRATCH_MNT > /dev/null 2>&1
-	_check_scratch_fs $DMTHIN_VOL_DEV
+	OLD_SCRATCH_DEV=$SCRATCH_DEV
+	SCRATCH_DEV=$DMTHIN_VOL_DEV
+	_check_scratch_fs
+	SCRATCH_DEV=$OLD_SCRATCH_DEV
+	unset OLD_SCRATCH_DEV
 }
 
 # Set up a dm-thin device on $SCRATCH_DEV
diff --git a/common/rc b/common/rc
index c3cdc220a29b..8618f77a00b5 100644
--- a/common/rc
+++ b/common/rc
@@ -3692,14 +3692,14 @@ _check_test_fs()
     esac
 }
 
-_check_scratch_fs()
+# check the file system passed in as $1
+_check_dev_fs()
 {
-    local device=$SCRATCH_DEV
-    [ $# -eq 1 ] && device=$1
+    local device=$1
 
     case $FSTYP in
     xfs)
-	_check_xfs_scratch_fs $device
+	_check_xfs_filesystem $device "none" "none"
 	;;
     udf)
 	_check_udf_filesystem $device $udf_fsize
@@ -3751,6 +3751,19 @@ _check_scratch_fs()
     esac
 }
 
+# check the scratch file system
+_check_scratch_fs()
+{
+	case $FSTYP in
+	xfs)
+		_check_xfs_scratch_fs $SCRATCH_DEV
+		;;
+	*)
+		_check_dev_fs $SCRATCH_DEV
+		;;
+	esac
+}
+
 _full_fstyp_details()
 {
      [ -z "$FSTYP" ] && FSTYP=xfs
diff --git a/tests/btrfs/176 b/tests/btrfs/176
index 86796c8814a0..f2619bdd8e44 100755
--- a/tests/btrfs/176
+++ b/tests/btrfs/176
@@ -37,7 +37,7 @@ swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
 # Deleting device 1 should work again after swapoff.
 $BTRFS_UTIL_PROG device delete "$scratch_dev1" "$SCRATCH_MNT"
 _scratch_unmount
-_check_scratch_fs "$scratch_dev2"
+_check_dev_fs "$scratch_dev2"
 
 echo "Replace device"
 _scratch_mkfs >> $seqres.full 2>&1
@@ -55,7 +55,7 @@ swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
 $BTRFS_UTIL_PROG replace start -fB "$scratch_dev1" "$scratch_dev2" "$SCRATCH_MNT" \
 	>> $seqres.full
 _scratch_unmount
-_check_scratch_fs "$scratch_dev2"
+_check_dev_fs "$scratch_dev2"
 
 # success, all done
 status=0
diff --git a/tests/generic/648 b/tests/generic/648
index 7473c9d33746..1bba78f062cf 100755
--- a/tests/generic/648
+++ b/tests/generic/648
@@ -133,7 +133,7 @@ if [ -f "$loopimg" ]; then
 		_metadump_dev $DMERROR_DEV $seqres.scratch.final.md
 		echo "final scratch mount failed"
 	fi
-	SCRATCH_RTDEV= SCRATCH_LOGDEV= _check_scratch_fs $loopimg
+	_check_dev_fs $loopimg
 fi
 
 # success, all done; let the test harness check the scratch fs
diff --git a/tests/xfs/601 b/tests/xfs/601
index df382402b958..44911ea389a7 100755
--- a/tests/xfs/601
+++ b/tests/xfs/601
@@ -39,7 +39,7 @@ copy_file=$testdir/copy.img
 
 echo copy
 $XFS_COPY_PROG $SCRATCH_DEV $copy_file >> $seqres.full
-_check_scratch_fs $copy_file
+_check_dev_fs $copy_file
 
 echo recopy
 $XFS_COPY_PROG $copy_file $SCRATCH_DEV >> $seqres.full
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 04/12] ext4/032: use _check_dev_fs
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (2 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 03/12] common: add a _check_dev_fs helper Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 23:24   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 05/12] generic/590: split XFS RT specific bits out Christoph Hellwig
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

_check_dev_fs is the new designated helper to check file systems on
arbitrary devices, use that instead of _check_generic_filesystem, which
is just an implementation detail.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/ext4/032 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/ext4/032 b/tests/ext4/032
index 690fcf066c11..043ae4f53505 100755
--- a/tests/ext4/032
+++ b/tests/ext4/032
@@ -66,7 +66,7 @@ ext4_online_resize()
 	$UMOUNT_PROG ${IMG_MNT}
 
 	echo "+++ check fs" | tee -a $seqres.full
-	_check_generic_filesystem $LOOP_DEVICE >> $seqres.full 2>&1 || \
+	_check_dev_fs $LOOP_DEVICE >> $seqres.full 2>&1 || \
 		_fail "fsck should not fail"
 	_destroy_loop_device $LOOP_DEVICE && LOOP_DEVICE=
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 05/12] generic/590: split XFS RT specific bits out
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (3 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 04/12] ext4/032: use _check_dev_fs Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 22:51   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Currently generic/590 runs a very different test on XFS that creates
a lot device and so on.  Split that out into a new XFS-specific test,
and let generic/590 always run using the file system parameter specified
in the config even for XFS.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/590 |  68 ++-------------------------
 tests/xfs/650     | 117 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/650.out |   2 +
 3 files changed, 123 insertions(+), 64 deletions(-)
 create mode 100755 tests/xfs/650
 create mode 100644 tests/xfs/650.out

diff --git a/tests/generic/590 b/tests/generic/590
index ba1337a856f1..54c26f2ae5ed 100755
--- a/tests/generic/590
+++ b/tests/generic/590
@@ -4,27 +4,15 @@
 #
 # FS QA Test 590
 #
-# Test commit 0c4da70c83d4 ("xfs: fix realtime file data space leak") and
-# 69ffe5960df1 ("xfs: don't check for AG deadlock for realtime files in
-# bunmapi"). On XFS without the fixes, truncate will hang forever. On other
-# filesystems, this just tests writing into big fallocates.
+# Tests writing into big fallocates.
+#
+# Based on an XFS RT subvolume specific test now split into xfs/650.
 #
 . ./common/preamble
 _begin_fstest auto prealloc preallocrw
 
-# Override the default cleanup function.
-_cleanup()
-{
-	_scratch_unmount &>/dev/null
-	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
-	cd /
-	rm -f $tmp.*
-	rm -f "$TEST_DIR/$seq"
-}
-
 . ./common/filter
 
-_require_scratch_nocheck
 _require_xfs_io_command "falloc"
 
 maxextlen=$((0x1fffff))
@@ -32,54 +20,7 @@ bs=4096
 rextsize=4
 filesz=$(((maxextlen + 1) * bs))
 
-must_disable_feature() {
-	local feat="$1"
-
-	# If mkfs doesn't know about the feature, we don't need to disable it
-	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
-
-	# If turning the feature on works, we don't need to disable it
-	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
-		> /dev/null 2>&1 && return 1
-
-	# Otherwise mkfs knows of the feature and formatting with it failed,
-	# so we do need to mask it.
-	return 0
-}
-
-extra_options=""
-# If we're testing XFS, set up the realtime device to reproduce the bug.
-if [[ $FSTYP = xfs ]]; then
-	# If we don't have a realtime device, set up a loop device on the test
-	# filesystem.
-	if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
-		_require_test
-		loopsz="$((filesz + (1 << 26)))"
-		_require_fs_space "$TEST_DIR" $((loopsz / 1024))
-		$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
-		loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
-		USE_EXTERNAL=yes
-		SCRATCH_RTDEV="$loop_dev"
-		disabled_features=()
-
-		# disable reflink if not supported by realtime devices
-		must_disable_feature reflink &&
-			disabled_features=(-m reflink=0)
-
-		# disable rmap if not supported by realtime devices
-		must_disable_feature rmapbt &&
-			disabled_features+=(-m rmapbt=0)
-	fi
-	extra_options="$extra_options -r extsize=$((bs * rextsize))"
-	extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
-
-	_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
-	_try_scratch_mount >>$seqres.full 2>&1 || \
-		_notrun "mount failed, kernel doesn't support realtime?"
-	_scratch_unmount
-else
-	_scratch_mkfs $extra_options >>$seqres.full 2>&1
-fi
+_scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
 _require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
 
@@ -112,7 +53,6 @@ $XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
 # Truncate the extents.
 $XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
 
-# We need to do this before the loop device gets torn down.
 _scratch_unmount
 _check_scratch_fs
 
diff --git a/tests/xfs/650 b/tests/xfs/650
new file mode 100755
index 000000000000..d8f70539665f
--- /dev/null
+++ b/tests/xfs/650
@@ -0,0 +1,117 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Facebook.  All Rights Reserved.
+#
+# FS QA Test 650
+#
+# Test commit 0c4da70c83d4 ("xfs: fix realtime file data space leak") and
+# 69ffe5960df1 ("xfs: don't check for AG deadlock for realtime files in
+# bunmapi"). On XFS without the fixes, truncate will hang forever.
+#
+. ./common/preamble
+_begin_fstest auto prealloc preallocrw
+
+# Override the default cleanup function.
+_cleanup()
+{
+	_scratch_unmount &>/dev/null
+	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
+	cd /
+	rm -f $tmp.*
+	rm -f "$TEST_DIR/$seq"
+}
+
+. ./common/filter
+
+_require_scratch_nocheck
+_require_xfs_io_command "falloc"
+
+maxextlen=$((0x1fffff))
+bs=4096
+rextsize=4
+filesz=$(((maxextlen + 1) * bs))
+
+must_disable_feature() {
+	local feat="$1"
+
+	# If mkfs doesn't know about the feature, we don't need to disable it
+	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
+
+	# If turning the feature on works, we don't need to disable it
+	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
+		> /dev/null 2>&1 && return 1
+
+	# Otherwise mkfs knows of the feature and formatting with it failed,
+	# so we do need to mask it.
+	return 0
+}
+
+extra_options=""
+# Set up the realtime device to reproduce the bug.
+
+# If we don't have a realtime device, set up a loop device on the test
+# filesystem.
+if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
+	_require_test
+	loopsz="$((filesz + (1 << 26)))"
+	_require_fs_space "$TEST_DIR" $((loopsz / 1024))
+	$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
+	loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
+	USE_EXTERNAL=yes
+	SCRATCH_RTDEV="$loop_dev"
+	disabled_features=()
+
+	# disable reflink if not supported by realtime devices
+	must_disable_feature reflink &&
+		disabled_features=(-m reflink=0)
+
+	# disable rmap if not supported by realtime devices
+	must_disable_feature rmapbt &&
+		disabled_features+=(-m rmapbt=0)
+fi
+extra_options="$extra_options -r extsize=$((bs * rextsize))"
+extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
+
+_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
+_try_scratch_mount >>$seqres.full 2>&1 || \
+	_notrun "mount failed, kernel doesn't support realtime?"
+_scratch_unmount
+_scratch_mount
+_require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
+
+# Allocate maxextlen + 1 blocks. As long as the allocator does something sane,
+# we should end up with two extents that look something like:
+#
+# u3.bmx[0-1] = [startoff,startblock,blockcount,extentflag]
+# 0:[0,0,2097148,1]
+# 1:[2097148,2097148,4,1]
+#
+# Extent 0 has blockcount = ALIGN_DOWN(maxextlen, rextsize). Extent 1 is
+# adjacent and has blockcount = rextsize. Both are unwritten.
+$XFS_IO_PROG -c "falloc 0 $filesz" -c fsync -f "$SCRATCH_MNT/file"
+
+# Write extent 0 + one block of extent 1. Our extents should end up like so:
+#
+# u3.bmx[0-1] = [startoff,startblock,blockcount,extentflag]
+# 0:[0,0,2097149,0]
+# 1:[2097149,2097149,3,1]
+#
+# Extent 0 is written and has blockcount = ALIGN_DOWN(maxextlen, rextsize) + 1,
+# Extent 1 is adjacent, unwritten, and has blockcount = rextsize - 1 and
+# startblock % rextsize = 1.
+#
+# The -b is just to speed things up (doing GBs of I/O in 4k chunks kind of
+# sucks).
+$XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
+	"$SCRATCH_MNT/file" >> "$seqres.full"
+
+# Truncate the extents.
+$XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
+
+# We need to do this before the loop device gets torn down.
+_scratch_unmount
+_check_scratch_fs
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/xfs/650.out b/tests/xfs/650.out
new file mode 100644
index 000000000000..d7a3e4b63483
--- /dev/null
+++ b/tests/xfs/650.out
@@ -0,0 +1,2 @@
+QA output created by 650
+Silence is golden
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (4 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 05/12] generic/590: split XFS RT specific bits out Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 20:05   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers Christoph Hellwig
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

This tests wants to test various difference device configurations,
and does so by overriding SCRATCH_{,LOG,RT}DEV.  This has two downside:

 1) the actual SCRATCH_{,LOG,RT}DEV configuration is still injected by
    default, thus making the test dependent on that configuration
 2) the MKFS_OPTIONS might not actually be compatible with the
    configuration created

Fix this by open coding the mkfs, db, admin and repair calls and always
run them on the specific configuration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/157 | 104 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 78 insertions(+), 26 deletions(-)

diff --git a/tests/xfs/157 b/tests/xfs/157
index e102a5a10abe..31f05db25724 100755
--- a/tests/xfs/157
+++ b/tests/xfs/157
@@ -50,53 +50,105 @@ fake_rtfile=$TEST_DIR/$seq.scratch.rt
 rm -f $fake_rtfile
 truncate -s $fs_size $fake_rtfile
 
-# Save the original variables
-orig_ddev=$SCRATCH_DEV
-orig_external=$USE_EXTERNAL
-orig_logdev=$SCRATCH_LOGDEV
-orig_rtdev=$SCRATCH_RTDEV
-
 scenario() {
 	echo "$@" | tee -a $seqres.full
 
-	SCRATCH_DEV=$orig_ddev
-	USE_EXTERNAL=$orig_external
-	SCRATCH_LOGDEV=$orig_logdev
-	SCRATCH_RTDEV=$orig_rtdev
+	dev=$SCRATCH_DEV
+	logdev=
+	rtdev=
+}
+
+_fake_mkfs()
+{
+	OPTIONS="$*"
+	if [ -n "$logdev" ]; then
+		OPTIONS="$OPTIONS -l logdev=$logdev"
+	fi
+	if [ -n "$rtdev" ]; then
+		OPTIONS="$OPTIONS -r rtdev=$rtdev"
+	fi
+	$MKFS_XFS_PROG -f $OPTIONS $dev || _fail "mkfs failed"
+}
+
+_fake_xfs_db_options()
+{
+	OPTIONS=""
+	if [ ! -z "$logdev" ]; then
+		OPTIONS="-l $logdev"
+	fi
+	if [ ! -z "$rtdev" ]; then
+		if [ $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev']; then
+			OPTIONS="$OPTIONS -R $rtdev"
+		fi
+	fi
+	echo $OPTIONS $* $dev
+}
+
+_fake_xfs_db()
+{
+	$XFS_DB_PROG "$@" $(_fake_xfs_db_options)
+}
+
+_fake_xfs_admin()
+{
+	local options=("$dev")
+	local rt_opts=()
+	if [ -n "$logdev" ]; then
+		options+=("$logdev")
+	fi
+	if [ -n "$rtdev" ]; then
+		$XFS_ADMIN_PROG --help 2>&1 | grep -q 'rtdev' || \
+			_notrun 'xfs_admin does not support rt devices'
+		rt_opts+=(-r "$rtdev")
+	fi
+
+	# xfs_admin in xfsprogs 5.11 has a bug where an external log device
+	# forces xfs_db to be invoked, potentially with zero command arguments.
+	# When this happens, xfs_db will wait for input on stdin, which causes
+	# fstests to hang.  Since xfs_admin is not an interactive tool, we
+	# can redirect stdin from /dev/null to prevent this issue.
+	$XFS_ADMIN_PROG "${rt_opts[@]}" "$@" "${options[@]}" < /dev/null
+}
+
+
+_fake_xfs_repair()
+{
+	OPTIONS=""
+	if [ -n "$logdev" ]; then
+		OPTIONS="-l $logdev"
+	fi
+	if [ -n "$rtdev" ]; then
+		OPTIONS="$OPTIONS -r $rtdev"
+	fi
+	$XFS_REPAIR_PROG $OPTIONS $* $dev
 }
 
 check_label() {
-	_scratch_mkfs_sized "$fs_size" "" -L oldlabel >> $seqres.full 2>&1
-	_scratch_xfs_db -c label
-	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
-	_scratch_xfs_db -c label
-	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
+	_fake_mkfs -L oldlabel >> $seqres.full 2>&1
+	_fake_xfs_db -c label
+	_fake_xfs_admin -L newlabel "$@" >> $seqres.full
+	_fake_xfs_db -c label
+	_fake_xfs_repair -n &>> $seqres.full || echo "Check failed?"
 }
 
 scenario "S1: Check that label setting with file image"
-SCRATCH_DEV=$fake_datafile
+dev=$fake_datafile
 check_label -f
 
 scenario "S2: Check that setting with logdev works"
-USE_EXTERNAL=yes
-SCRATCH_LOGDEV=$fake_logfile
+logdev=$fake_logfile
 check_label
 
 scenario "S3: Check that setting with rtdev works"
-USE_EXTERNAL=yes
-SCRATCH_RTDEV=$fake_rtfile
+rtdev=$fake_rtfile
 check_label
 
 scenario "S4: Check that setting with rtdev + logdev works"
-USE_EXTERNAL=yes
-SCRATCH_LOGDEV=$fake_logfile
-SCRATCH_RTDEV=$fake_rtfile
+logdev=$fake_logfile
+rtdev=$fake_rtfile
 check_label
 
 scenario "S5: Check that setting with nortdev + nologdev works"
-USE_EXTERNAL=
-SCRATCH_LOGDEV=
-SCRATCH_RTDEV=
 check_label
 
 scenario "S6: Check that setting with bdev incorrectly flagged as file works"
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (5 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 20:02   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers Christoph Hellwig
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

This tests creates loop-based data and rt devices for testing.  Don't
override SCRATCH_{,RT}DEV and don't use the helpers based on it because
the options specified in MKFS_OPTIONS might not work for this
configuration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/185 | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/tests/xfs/185 b/tests/xfs/185
index 7aceb383ce46..84139be8e66e 100755
--- a/tests/xfs/185
+++ b/tests/xfs/185
@@ -22,12 +22,11 @@ _cleanup()
 {
 	cd /
 	rm -r -f $tmp.*
-	_scratch_unmount
+	umount $SCRATCH_MNT
 	test -n "$ddloop" && _destroy_loop_device "$ddloop"
 	test -n "$rtloop" && _destroy_loop_device "$rtloop"
 	test -n "$ddfile" && rm -f "$ddfile"
 	test -n "$rtfile" && rm -f "$rtfile"
-	test -n "$old_use_external" && USE_EXTERNAL="$old_use_external"
 }
 
 _require_test
@@ -64,16 +63,8 @@ rtminor=$(stat -c '%T' "$rtloop")
 test $ddmajor -le $rtmajor || \
 	_notrun "Data loopdev minor $ddminor larger than rt minor $rtminor"
 
-# Inject our custom-built devices as an rt-capable scratch device.
-# We avoid touching "require_scratch" so that post-test fsck will not try to
-# run on our synthesized scratch device.
-old_use_external="$USE_EXTERNAL"
-USE_EXTERNAL=yes
-SCRATCH_RTDEV="$rtloop"
-SCRATCH_DEV="$ddloop"
-
-_scratch_mkfs >> $seqres.full
-_try_scratch_mount >> $seqres.full || \
+$MKFS_XFS_PROG -r rtdev=$rtloop $ddloop  >> $seqres.full
+mount -o rtdev=$rtloop $ddloop $SCRATCH_MNT >> $seqres.full || \
 	_notrun "mount with injected rt device failed"
 
 # Create a file that we'll use to seed fsmap entries for the rt device,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (6 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 19:55   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV Christoph Hellwig
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

This tests forces external devices to be disabled by calling mkfs.xfs
directly and overriding SCRATCH_{LOG,RT}DEV, but the options specified in
MKFS_OPTIONS might not work for this configuration.  Instead hard code
the calls to xfs_db and don't modify the scratch device configuration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/424 | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/tests/xfs/424 b/tests/xfs/424
index 6078d34897e7..61e9de375383 100755
--- a/tests/xfs/424
+++ b/tests/xfs/424
@@ -25,17 +25,11 @@ filter_dbval()
 	awk '{ print $4 }'
 }
 
-# Import common functions.
 . ./common/filter
 
-# Modify as appropriate
-
-# Since we have an open-coded mkfs call, disable the external devices and
-# don't let the post-check fsck actually run since it'll trip over us not
-# using the external devices.
+# Since we have an open-coded mkfs call, don't let the post-check fsck run since
+# it would trip over us not using the external devices.
 _require_scratch_nocheck
-export SCRATCH_LOGDEV=
-export SCRATCH_RTDEV=
 
 echo "Silence is golden."
 
@@ -62,30 +56,31 @@ for SECTOR_SIZE in $sector_sizes; do
 		grep -q 'finobt=1' && finobt_enabled=1
 
 	for TYPE in agf agi agfl sb; do
-		DADDR=`_scratch_xfs_db -c "$TYPE" -c "daddr" | filter_dbval`
-		_scratch_xfs_db -c "daddr $DADDR" -c "type $TYPE"
+		DADDR=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV |
+			filter_dbval`
+		$XFS_DB_PROG -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
 	done
 
-	DADDR=`_scratch_xfs_db -c "sb" -c "addr rootino" -c "daddr" |
+	DADDR=`$XFS_DB_PROG -c "sb" -c "addr rootino" -c "daddr" $SCRATCH_DEV |
 		filter_dbval`
-	_scratch_xfs_db -c "daddr $DADDR" -c "type inode"
-	DADDR=`_scratch_xfs_db -c "agf" -c "addr bnoroot" -c "daddr" |
+	$XFS_DB_PROG -c "daddr $DADDR" -c "type inode" $SCRATCH_DEV
+	DADDR=`$XFS_DB_PROG -c "agf" -c "addr bnoroot" -c "daddr" $SCRATCH_DEV |
 		filter_dbval`
-	_scratch_xfs_db -c "daddr $DADDR" -c "type bnobt"
-	DADDR=`_scratch_xfs_db -c "agf" -c "addr cntroot" -c "daddr" |
+	$XFS_DB_PROG -c "daddr $DADDR" -c "type bnobt" $SCRATCH_DEV
+	DADDR=`$XFS_DB_PROG -c "agf" -c "addr cntroot" -c "daddr" $SCRATCH_DEV |
 		filter_dbval`
-	_scratch_xfs_db -c "daddr $DADDR" -c "type cntbt"
-	DADDR=`_scratch_xfs_db -c "agi" -c "addr root" -c "daddr" |
+	$XFS_DB_PROG -c "daddr $DADDR" -c "type cntbt" $SCRATCH_DEV
+	DADDR=`$XFS_DB_PROG -c "agi" -c "addr root" -c "daddr" $SCRATCH_DEV |
 		filter_dbval`
-	_scratch_xfs_db -c "daddr $DADDR" -c "type inobt"
+	$XFS_DB_PROG -c "daddr $DADDR" -c "type inobt" $SCRATCH_DEV
 	if [ $finobt_enabled -eq 1 ]; then
-		DADDR=`_scratch_xfs_db -c "agi" -c "addr free_root" -c "daddr" |
-			filter_dbval`
-		_scratch_xfs_db -c "daddr $DADDR" -c "type finobt"
+		DADDR=`$XFS_DB_PROG -c "agi" -c "addr free_root" -c "daddr" $SCRATCH_DEV |
+			 filter_dbval`
+		$XFS_DB_PROG -c "daddr $DADDR" -c "type finobt" $SCRATCH_DEV
 	fi
 
-	_scratch_xfs_db -c "daddr $DADDR" -c "type text"
-	_scratch_xfs_db -c "daddr $DADDR" -c "type data"
+	$XFS_DB_PROG -c "daddr $DADDR" -c "type text" $SCRATCH_DEV
+	$XFS_DB_PROG -c "daddr $DADDR" -c "type data" $SCRATCH_DEV
 done
 
 # success, all done
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (7 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 19:54   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 10/12] xfs/528: " Christoph Hellwig
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Require a real SCRATCH_RTDEV instead of faking one up using a loop
device, as otherwise the options specified in MKFS_OPTIONS might
not actually work the configuration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/521     | 33 ++++++++-------------------------
 tests/xfs/521.out |  1 -
 2 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/tests/xfs/521 b/tests/xfs/521
index 0da05a55a276..5cd6649c50c7 100755
--- a/tests/xfs/521
+++ b/tests/xfs/521
@@ -16,34 +16,16 @@
 . ./common/preamble
 _begin_fstest auto quick realtime growfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount >> $seqres.full 2>&1
-	[ -n "$rt_loop_dev" ] && _destroy_loop_device $rt_loop_dev
-	rm -f $tmp.* $TEST_DIR/$seq.rtvol
-}
-
-# Import common functions.
 . ./common/filter
 
-# Note that we don't _require_realtime because we synthesize a rt volume
-# below.
-_require_scratch_nocheck
-_require_no_large_scratch_dev
-
-echo "Create fake rt volume"
-truncate -s 400m $TEST_DIR/$seq.rtvol
-rt_loop_dev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
+_require_realtime
+_require_scratch
 
 echo "Format and mount 100m rt volume"
-export USE_EXTERNAL=yes
-export SCRATCH_RTDEV=$rtdev
 _scratch_mkfs -r size=100m > $seqres.full
-_try_scratch_mount || _notrun "Could not mount scratch with synthetic rt volume"
+_scratch_mount
 
-# zoned file systems only support zoned size-rounded RT device sizes
+# zoned file systems only support zone-size aligned RT device sizes
 _require_xfs_scratch_non_zoned
 
 testdir=$SCRATCH_MNT/test-$seq
@@ -58,7 +40,10 @@ echo "Create some files"
 _pwrite_byte 0x61 0 1m $testdir/original >> $seqres.full
 
 echo "Grow fs"
-$XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 |  _filter_growfs >> $seqres.full
+# growfs expects sizes in FSB units
+fsbsize=$(_get_block_size $SCRATCH_MNT)
+$XFS_GROWFS_PROG -R $((400 * 1024 * 1024 / fsbsize)) $SCRATCH_MNT 2>&1 | \
+	  _filter_growfs >> $seqres.full
 _scratch_cycle_mount
 
 echo "Recheck 400m rt volume stats"
@@ -73,8 +58,6 @@ echo "Check filesystem"
 _check_scratch_fs
 
 _scratch_unmount
-_destroy_loop_device $rt_loop_dev
-unset rt_loop_dev
 
 # success, all done
 status=0
diff --git a/tests/xfs/521.out b/tests/xfs/521.out
index 007ab92c6db2..afd18bb0dc99 100644
--- a/tests/xfs/521.out
+++ b/tests/xfs/521.out
@@ -1,5 +1,4 @@
 QA output created by 521
-Create fake rt volume
 Format and mount 100m rt volume
 Check rt volume stats
 Create some files
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 10/12] xfs/528: require a real SCRATCH_RTDEV
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (8 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 19:52   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 11/12] xfs/530: " Christoph Hellwig
  2025-12-10  5:46 ` [PATCH 12/12] xfs/650: " Christoph Hellwig
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Require a real SCRATCH_RTDEV instead of faking one up using a loop
device, as otherwise the options specified in MKFS_OPTIONS might
not actually work the configuration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/528     | 34 ++++------------------------------
 tests/xfs/528.out |  2 --
 2 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/tests/xfs/528 b/tests/xfs/528
index a1efbbd27b96..c83545e959dc 100755
--- a/tests/xfs/528
+++ b/tests/xfs/528
@@ -10,27 +10,16 @@
 . ./common/preamble
 _begin_fstest auto quick insert zero collapse punch rw realtime
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount >> $seqres.full 2>&1
-	[ -n "$rt_loop_dev" ] && _destroy_loop_device $rt_loop_dev
-	rm -f $tmp.* $TEST_DIR/$seq.rtvol
-}
-
-# Import common functions.
 . ./common/filter
 
-_require_loop
 _require_command "$FILEFRAG_PROG" filefrag
 _require_xfs_io_command "fpunch"
 _require_xfs_io_command "fzero"
 _require_xfs_io_command "fcollapse"
 _require_xfs_io_command "finsert"
-# Note that we don't _require_realtime because we synthesize a rt volume
-# below.  This also means we cannot run the post-test check.
-_require_scratch_nocheck
+
+_require_realtime
+_require_scratch
 
 log() {
 	echo "$@" | tee -a $seqres.full
@@ -63,7 +52,6 @@ test_ops() {
 	local lunaligned_off=$unaligned_sz
 
 	log "Format rtextsize=$rextsize"
-	_scratch_unmount
 	_scratch_mkfs -r extsize=$rextsize >> $seqres.full
 	_try_scratch_mount || \
 		_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
@@ -150,30 +138,16 @@ test_ops() {
 	check_file $SCRATCH_MNT/lpunch
 
 	log "Check everything, rextsize=$rextsize"
+	_scratch_unmount
 	_check_scratch_fs
 }
 
-echo "Create fake rt volume"
-$XFS_IO_PROG -f -c "truncate 400m" $TEST_DIR/$seq.rtvol
-rt_loop_dev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
-
-echo "Make sure synth rt volume works"
-export USE_EXTERNAL=yes
-export SCRATCH_RTDEV=$rt_loop_dev
-_scratch_mkfs > $seqres.full
-_try_scratch_mount || \
-	_notrun "Could not mount with synthetic rt volume"
-
 # power of two
 test_ops 262144
 
 # not a power of two
 test_ops 327680
 
-_scratch_unmount
-_destroy_loop_device $rt_loop_dev
-unset rt_loop_dev
-
 # success, all done
 status=0
 exit
diff --git a/tests/xfs/528.out b/tests/xfs/528.out
index 0e081706618c..08de4c28b16c 100644
--- a/tests/xfs/528.out
+++ b/tests/xfs/528.out
@@ -1,6 +1,4 @@
 QA output created by 528
-Create fake rt volume
-Make sure synth rt volume works
 Format rtextsize=262144
 Test regular write, rextsize=262144
 2dce060217cb2293dde96f7fdb3b9232  SCRATCH_MNT/write
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 11/12] xfs/530: require a real SCRATCH_RTDEV
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (9 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 10/12] xfs/528: " Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 19:49   ` Darrick J. Wong
  2025-12-10  5:46 ` [PATCH 12/12] xfs/650: " Christoph Hellwig
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Require a real SCRATCH_RTDEV instead of faking one up using a loop
device, as otherwise the options specified in MKFS_OPTIONS might
not actually work the configuration.

Note that specifying a rtextsize doesn't work for zoned file systems,
so _notrun when mkfs fails.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/530     | 42 +++++++++++++-----------------------------
 tests/xfs/530.out |  1 -
 2 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/tests/xfs/530 b/tests/xfs/530
index 4a41127e3b82..ffc9e902e1b7 100755
--- a/tests/xfs/530
+++ b/tests/xfs/530
@@ -10,36 +10,22 @@
 . ./common/preamble
 _begin_fstest auto quick realtime growfs
 
-# Override the default cleanup function.
-_cleanup()
-{
-	cd /
-	_scratch_unmount >> $seqres.full 2>&1
-	[ -n "$rt_loop_dev" ] && _destroy_loop_device $rt_loop_dev
-	rm -f $tmp.* $TEST_DIR/$seq.rtvol
-}
-
-# Import common functions.
 . ./common/filter
 . ./common/inject
 . ./common/populate
 
-
-# Note that we don't _require_realtime because we synthesize a rt volume
-# below.
-_require_test
+_require_scratch
+_require_realtime
 _require_xfs_debug
 _require_test_program "punch-alternating"
 _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
-_require_scratch_nocheck
 
 echo "* Test extending rt inodes"
 
 _scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs
 . $tmp.mkfs
 
-echo "Create fake rt volume"
 nr_bitmap_blks=25
 nr_bits=$((nr_bitmap_blks * dbsize * 8))
 
@@ -50,17 +36,12 @@ else
 	rtextsz=$dbsize
 fi
 
-rtdevsz=$((nr_bits * rtextsz))
-truncate -s $rtdevsz $TEST_DIR/$seq.rtvol
-rt_loop_dev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
-
 echo "Format and mount rt volume"
-
-export USE_EXTERNAL=yes
-export SCRATCH_RTDEV=$rt_loop_dev
-_scratch_mkfs -d size=$((1024 * 1024 * 1024)) \
-	      -r size=${rtextsz},extsize=${rtextsz} >> $seqres.full
-_try_scratch_mount || _notrun "Couldn't mount fs with synthetic rt volume"
+_try_scratch_mkfs_xfs \
+	-d size=$((1024 * 1024 * 1024)) \
+	-r size=${rtextsz},extsize=${rtextsz} >> $seqres.full 2>&1 || \
+	_notrun "Couldn't created crafted fs (zoned?)"
+_try_scratch_mount || _notrun "Couldn't mount crafted fs"
 
 # If we didn't get the desired realtime volume and the same blocksize as the
 # first format (which we used to compute a specific rt geometry), skip the
@@ -92,7 +73,12 @@ echo "Inject bmap_alloc_minlen_extent error tag"
 _scratch_inject_error bmap_alloc_minlen_extent 1
 
 echo "Grow realtime volume"
-$XFS_GROWFS_PROG -r $SCRATCH_MNT >> $seqres.full 2>&1
+# growfs expects sizes in FSB units
+fsbsize=$(_get_block_size $SCRATCH_MNT)
+rtdevsz=$((nr_bits * rtextsz))
+
+$XFS_GROWFS_PROG -R $((rtdevsize / fsbsize)) $SCRATCH_MNT \
+	>> $seqres.full 2>&1
 if [[ $? == 0 ]]; then
 	echo "Growfs succeeded; should have failed."
 	exit 1
@@ -115,8 +101,6 @@ echo "Check filesystem"
 _check_scratch_fs
 
 _scratch_unmount &> /dev/null
-_destroy_loop_device $rt_loop_dev
-unset rt_loop_dev
 
 # success, all done
 status=0
diff --git a/tests/xfs/530.out b/tests/xfs/530.out
index 6ddb572f9435..3c508b4564f7 100644
--- a/tests/xfs/530.out
+++ b/tests/xfs/530.out
@@ -1,6 +1,5 @@
 QA output created by 530
 * Test extending rt inodes
-Create fake rt volume
 Format and mount rt volume
 Consume free space
 Create fragmented filesystem
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 12/12] xfs/650:  require a real SCRATCH_RTDEV
  2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
                   ` (10 preceding siblings ...)
  2025-12-10  5:46 ` [PATCH 11/12] xfs/530: " Christoph Hellwig
@ 2025-12-10  5:46 ` Christoph Hellwig
  2025-12-10 19:45   ` Darrick J. Wong
  11 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:46 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Anand Jain, Filipe Manana, Darrick J. Wong, fstests, linux-ext4,
	linux-xfs

Require a real SCRATCH_RTDEV instead of faking one up using a loop
device, as otherwise the options specified in MKFS_OPTIONS might
not actually work the configuration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/650 | 63 +++++----------------------------------------------
 1 file changed, 6 insertions(+), 57 deletions(-)

diff --git a/tests/xfs/650 b/tests/xfs/650
index d8f70539665f..418a1e7aae7c 100755
--- a/tests/xfs/650
+++ b/tests/xfs/650
@@ -9,21 +9,11 @@
 # bunmapi"). On XFS without the fixes, truncate will hang forever.
 #
 . ./common/preamble
-_begin_fstest auto prealloc preallocrw
-
-# Override the default cleanup function.
-_cleanup()
-{
-	_scratch_unmount &>/dev/null
-	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
-	cd /
-	rm -f $tmp.*
-	rm -f "$TEST_DIR/$seq"
-}
+_begin_fstest auto prealloc preallocrw realtime
 
 . ./common/filter
 
-_require_scratch_nocheck
+_require_realtime
 _require_xfs_io_command "falloc"
 
 maxextlen=$((0x1fffff))
@@ -31,51 +21,11 @@ bs=4096
 rextsize=4
 filesz=$(((maxextlen + 1) * bs))
 
-must_disable_feature() {
-	local feat="$1"
-
-	# If mkfs doesn't know about the feature, we don't need to disable it
-	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
-
-	# If turning the feature on works, we don't need to disable it
-	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
-		> /dev/null 2>&1 && return 1
-
-	# Otherwise mkfs knows of the feature and formatting with it failed,
-	# so we do need to mask it.
-	return 0
-}
-
-extra_options=""
-# Set up the realtime device to reproduce the bug.
+_scratch_mkfs \
+	-d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1 \
+	-r extsize=$((bs * rextsize)) \
+	>>$seqres.full 2>&1
 
-# If we don't have a realtime device, set up a loop device on the test
-# filesystem.
-if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
-	_require_test
-	loopsz="$((filesz + (1 << 26)))"
-	_require_fs_space "$TEST_DIR" $((loopsz / 1024))
-	$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
-	loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
-	USE_EXTERNAL=yes
-	SCRATCH_RTDEV="$loop_dev"
-	disabled_features=()
-
-	# disable reflink if not supported by realtime devices
-	must_disable_feature reflink &&
-		disabled_features=(-m reflink=0)
-
-	# disable rmap if not supported by realtime devices
-	must_disable_feature rmapbt &&
-		disabled_features+=(-m rmapbt=0)
-fi
-extra_options="$extra_options -r extsize=$((bs * rextsize))"
-extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
-
-_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
-_try_scratch_mount >>$seqres.full 2>&1 || \
-	_notrun "mount failed, kernel doesn't support realtime?"
-_scratch_unmount
 _scratch_mount
 _require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
 
@@ -108,7 +58,6 @@ $XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
 # Truncate the extents.
 $XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
 
-# We need to do this before the loop device gets torn down.
 _scratch_unmount
 _check_scratch_fs
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 02/12] ext4/006: call e2fsck directly
  2025-12-10  5:46 ` [PATCH 02/12] ext4/006: call e2fsck directly Christoph Hellwig
@ 2025-12-10 19:32   ` Darrick J. Wong
  2025-12-11  4:52     ` Christoph Hellwig
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 19:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:48AM +0100, Christoph Hellwig wrote:
> _check_scratch_fs takes an optional device name, but no optional
> arguments.  Call e2fsck directly for this extN-specific test instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/ext4/006 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/ext4/006 b/tests/ext4/006
> index 2ece22a4bd1e..07dcf356b0bc 100755
> --- a/tests/ext4/006
> +++ b/tests/ext4/006
> @@ -44,7 +44,7 @@ repair_scratch() {
>  	res=$?
>  	if [ "${res}" -eq 0 ]; then
>  		echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
> -		_check_scratch_fs -n >> "${FSCK_LOG}" 2>&1
> +		e2fsck -n >> "${FSCK_LOG}" 2>&1

Doesn't this need a device name?  e.g. e2fsck -n $SCRATCH_DEV ?

--D

>  		res=$?
>  	fi
>  	echo "++ fsck returns ${res}" >> "${FSCK_LOG}"
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 12/12] xfs/650:  require a real SCRATCH_RTDEV
  2025-12-10  5:46 ` [PATCH 12/12] xfs/650: " Christoph Hellwig
@ 2025-12-10 19:45   ` Darrick J. Wong
  2025-12-10 22:50     ` Darrick J. Wong
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 19:45 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:58AM +0100, Christoph Hellwig wrote:
> Require a real SCRATCH_RTDEV instead of faking one up using a loop
> device, as otherwise the options specified in MKFS_OPTIONS might
> not actually work the configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/xfs/650 | 63 +++++----------------------------------------------

Er... what test is xfs/650?  There isn't one in for-next.

--D

>  1 file changed, 6 insertions(+), 57 deletions(-)
> 
> diff --git a/tests/xfs/650 b/tests/xfs/650
> index d8f70539665f..418a1e7aae7c 100755
> --- a/tests/xfs/650
> +++ b/tests/xfs/650
> @@ -9,21 +9,11 @@
>  # bunmapi"). On XFS without the fixes, truncate will hang forever.
>  #
>  . ./common/preamble
> -_begin_fstest auto prealloc preallocrw
> -
> -# Override the default cleanup function.
> -_cleanup()
> -{
> -	_scratch_unmount &>/dev/null
> -	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
> -	cd /
> -	rm -f $tmp.*
> -	rm -f "$TEST_DIR/$seq"
> -}
> +_begin_fstest auto prealloc preallocrw realtime
>  
>  . ./common/filter
>  
> -_require_scratch_nocheck
> +_require_realtime
>  _require_xfs_io_command "falloc"
>  
>  maxextlen=$((0x1fffff))
> @@ -31,51 +21,11 @@ bs=4096
>  rextsize=4
>  filesz=$(((maxextlen + 1) * bs))
>  
> -must_disable_feature() {
> -	local feat="$1"
> -
> -	# If mkfs doesn't know about the feature, we don't need to disable it
> -	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
> -
> -	# If turning the feature on works, we don't need to disable it
> -	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
> -		> /dev/null 2>&1 && return 1
> -
> -	# Otherwise mkfs knows of the feature and formatting with it failed,
> -	# so we do need to mask it.
> -	return 0
> -}
> -
> -extra_options=""
> -# Set up the realtime device to reproduce the bug.
> +_scratch_mkfs \
> +	-d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1 \
> +	-r extsize=$((bs * rextsize)) \
> +	>>$seqres.full 2>&1
>  
> -# If we don't have a realtime device, set up a loop device on the test
> -# filesystem.
> -if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
> -	_require_test
> -	loopsz="$((filesz + (1 << 26)))"
> -	_require_fs_space "$TEST_DIR" $((loopsz / 1024))
> -	$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
> -	loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
> -	USE_EXTERNAL=yes
> -	SCRATCH_RTDEV="$loop_dev"
> -	disabled_features=()
> -
> -	# disable reflink if not supported by realtime devices
> -	must_disable_feature reflink &&
> -		disabled_features=(-m reflink=0)
> -
> -	# disable rmap if not supported by realtime devices
> -	must_disable_feature rmapbt &&
> -		disabled_features+=(-m rmapbt=0)
> -fi
> -extra_options="$extra_options -r extsize=$((bs * rextsize))"
> -extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
> -
> -_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
> -_try_scratch_mount >>$seqres.full 2>&1 || \
> -	_notrun "mount failed, kernel doesn't support realtime?"
> -_scratch_unmount
>  _scratch_mount
>  _require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
>  
> @@ -108,7 +58,6 @@ $XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
>  # Truncate the extents.
>  $XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
>  
> -# We need to do this before the loop device gets torn down.
>  _scratch_unmount
>  _check_scratch_fs
>  
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 11/12] xfs/530: require a real SCRATCH_RTDEV
  2025-12-10  5:46 ` [PATCH 11/12] xfs/530: " Christoph Hellwig
@ 2025-12-10 19:49   ` Darrick J. Wong
  2025-12-11  4:55     ` Christoph Hellwig
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 19:49 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:57AM +0100, Christoph Hellwig wrote:
> Require a real SCRATCH_RTDEV instead of faking one up using a loop
> device, as otherwise the options specified in MKFS_OPTIONS might
> not actually work the configuration.
> 
> Note that specifying a rtextsize doesn't work for zoned file systems,
> so _notrun when mkfs fails.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/xfs/530     | 42 +++++++++++++-----------------------------
>  tests/xfs/530.out |  1 -
>  2 files changed, 13 insertions(+), 30 deletions(-)
> 
> diff --git a/tests/xfs/530 b/tests/xfs/530
> index 4a41127e3b82..ffc9e902e1b7 100755
> --- a/tests/xfs/530
> +++ b/tests/xfs/530
> @@ -10,36 +10,22 @@
>  . ./common/preamble
>  _begin_fstest auto quick realtime growfs
>  
> -# Override the default cleanup function.
> -_cleanup()
> -{
> -	cd /
> -	_scratch_unmount >> $seqres.full 2>&1
> -	[ -n "$rt_loop_dev" ] && _destroy_loop_device $rt_loop_dev
> -	rm -f $tmp.* $TEST_DIR/$seq.rtvol
> -}
> -
> -# Import common functions.
>  . ./common/filter
>  . ./common/inject
>  . ./common/populate
>  
> -
> -# Note that we don't _require_realtime because we synthesize a rt volume
> -# below.
> -_require_test
> +_require_scratch
> +_require_realtime
>  _require_xfs_debug
>  _require_test_program "punch-alternating"
>  _require_xfs_io_error_injection "reduce_max_iextents"
>  _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
> -_require_scratch_nocheck
>  
>  echo "* Test extending rt inodes"
>  
>  _scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs
>  . $tmp.mkfs
>  
> -echo "Create fake rt volume"
>  nr_bitmap_blks=25
>  nr_bits=$((nr_bitmap_blks * dbsize * 8))
>  
> @@ -50,17 +36,12 @@ else
>  	rtextsz=$dbsize
>  fi
>  
> -rtdevsz=$((nr_bits * rtextsz))
> -truncate -s $rtdevsz $TEST_DIR/$seq.rtvol
> -rt_loop_dev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
> -
>  echo "Format and mount rt volume"
> -
> -export USE_EXTERNAL=yes
> -export SCRATCH_RTDEV=$rt_loop_dev
> -_scratch_mkfs -d size=$((1024 * 1024 * 1024)) \
> -	      -r size=${rtextsz},extsize=${rtextsz} >> $seqres.full
> -_try_scratch_mount || _notrun "Couldn't mount fs with synthetic rt volume"
> +_try_scratch_mkfs_xfs \
> +	-d size=$((1024 * 1024 * 1024)) \
> +	-r size=${rtextsz},extsize=${rtextsz} >> $seqres.full 2>&1 || \
> +	_notrun "Couldn't created crafted fs (zoned?)"
> +_try_scratch_mount || _notrun "Couldn't mount crafted fs"
>  
>  # If we didn't get the desired realtime volume and the same blocksize as the
>  # first format (which we used to compute a specific rt geometry), skip the
> @@ -92,7 +73,12 @@ echo "Inject bmap_alloc_minlen_extent error tag"
>  _scratch_inject_error bmap_alloc_minlen_extent 1
>  
>  echo "Grow realtime volume"
> -$XFS_GROWFS_PROG -r $SCRATCH_MNT >> $seqres.full 2>&1
> +# growfs expects sizes in FSB units
> +fsbsize=$(_get_block_size $SCRATCH_MNT)
> +rtdevsz=$((nr_bits * rtextsz))
> +
> +$XFS_GROWFS_PROG -R $((rtdevsize / fsbsize)) $SCRATCH_MNT \

Why doesn't growfs -r still work here?

--D

> +	>> $seqres.full 2>&1
>  if [[ $? == 0 ]]; then
>  	echo "Growfs succeeded; should have failed."
>  	exit 1
> @@ -115,8 +101,6 @@ echo "Check filesystem"
>  _check_scratch_fs
>  
>  _scratch_unmount &> /dev/null
> -_destroy_loop_device $rt_loop_dev
> -unset rt_loop_dev
>  
>  # success, all done
>  status=0
> diff --git a/tests/xfs/530.out b/tests/xfs/530.out
> index 6ddb572f9435..3c508b4564f7 100644
> --- a/tests/xfs/530.out
> +++ b/tests/xfs/530.out
> @@ -1,6 +1,5 @@
>  QA output created by 530
>  * Test extending rt inodes
> -Create fake rt volume
>  Format and mount rt volume
>  Consume free space
>  Create fragmented filesystem
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 10/12] xfs/528: require a real SCRATCH_RTDEV
  2025-12-10  5:46 ` [PATCH 10/12] xfs/528: " Christoph Hellwig
@ 2025-12-10 19:52   ` Darrick J. Wong
  2025-12-11  4:57     ` Christoph Hellwig
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 19:52 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:56AM +0100, Christoph Hellwig wrote:
> Require a real SCRATCH_RTDEV instead of faking one up using a loop
> device, as otherwise the options specified in MKFS_OPTIONS might
> not actually work the configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/xfs/528     | 34 ++++------------------------------
>  tests/xfs/528.out |  2 --
>  2 files changed, 4 insertions(+), 32 deletions(-)
> 
> diff --git a/tests/xfs/528 b/tests/xfs/528
> index a1efbbd27b96..c83545e959dc 100755
> --- a/tests/xfs/528
> +++ b/tests/xfs/528
> @@ -10,27 +10,16 @@
>  . ./common/preamble
>  _begin_fstest auto quick insert zero collapse punch rw realtime
>  
> -# Override the default cleanup function.
> -_cleanup()
> -{
> -	cd /
> -	_scratch_unmount >> $seqres.full 2>&1
> -	[ -n "$rt_loop_dev" ] && _destroy_loop_device $rt_loop_dev
> -	rm -f $tmp.* $TEST_DIR/$seq.rtvol
> -}
> -
> -# Import common functions.
>  . ./common/filter
>  
> -_require_loop
>  _require_command "$FILEFRAG_PROG" filefrag
>  _require_xfs_io_command "fpunch"
>  _require_xfs_io_command "fzero"
>  _require_xfs_io_command "fcollapse"
>  _require_xfs_io_command "finsert"
> -# Note that we don't _require_realtime because we synthesize a rt volume
> -# below.  This also means we cannot run the post-test check.
> -_require_scratch_nocheck
> +
> +_require_realtime
> +_require_scratch
>  
>  log() {
>  	echo "$@" | tee -a $seqres.full
> @@ -63,7 +52,6 @@ test_ops() {
>  	local lunaligned_off=$unaligned_sz
>  
>  	log "Format rtextsize=$rextsize"
> -	_scratch_unmount
>  	_scratch_mkfs -r extsize=$rextsize >> $seqres.full
>  	_try_scratch_mount || \
>  		_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
> @@ -150,30 +138,16 @@ test_ops() {
>  	check_file $SCRATCH_MNT/lpunch
>  
>  	log "Check everything, rextsize=$rextsize"
> +	_scratch_unmount
>  	_check_scratch_fs

Why does _scratch_unmount move to this part of the loop?  Unmounting the
filesystem means that _check_xfs_filesystem won't run xfs_scrub on it.

(Everything else looks ok.)

--D

>  }
>  
> -echo "Create fake rt volume"
> -$XFS_IO_PROG -f -c "truncate 400m" $TEST_DIR/$seq.rtvol
> -rt_loop_dev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
> -
> -echo "Make sure synth rt volume works"
> -export USE_EXTERNAL=yes
> -export SCRATCH_RTDEV=$rt_loop_dev
> -_scratch_mkfs > $seqres.full
> -_try_scratch_mount || \
> -	_notrun "Could not mount with synthetic rt volume"
> -
>  # power of two
>  test_ops 262144
>  
>  # not a power of two
>  test_ops 327680
>  
> -_scratch_unmount
> -_destroy_loop_device $rt_loop_dev
> -unset rt_loop_dev
> -
>  # success, all done
>  status=0
>  exit
> diff --git a/tests/xfs/528.out b/tests/xfs/528.out
> index 0e081706618c..08de4c28b16c 100644
> --- a/tests/xfs/528.out
> +++ b/tests/xfs/528.out
> @@ -1,6 +1,4 @@
>  QA output created by 528
> -Create fake rt volume
> -Make sure synth rt volume works
>  Format rtextsize=262144
>  Test regular write, rextsize=262144
>  2dce060217cb2293dde96f7fdb3b9232  SCRATCH_MNT/write
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV
  2025-12-10  5:46 ` [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV Christoph Hellwig
@ 2025-12-10 19:54   ` Darrick J. Wong
  2025-12-11  4:58     ` Christoph Hellwig
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 19:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:55AM +0100, Christoph Hellwig wrote:
> Require a real SCRATCH_RTDEV instead of faking one up using a loop
> device, as otherwise the options specified in MKFS_OPTIONS might
> not actually work the configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/xfs/521     | 33 ++++++++-------------------------
>  tests/xfs/521.out |  1 -
>  2 files changed, 8 insertions(+), 26 deletions(-)
> 
> diff --git a/tests/xfs/521 b/tests/xfs/521
> index 0da05a55a276..5cd6649c50c7 100755
> --- a/tests/xfs/521
> +++ b/tests/xfs/521
> @@ -16,34 +16,16 @@
>  . ./common/preamble
>  _begin_fstest auto quick realtime growfs
>  
> -# Override the default cleanup function.
> -_cleanup()
> -{
> -	cd /
> -	_scratch_unmount >> $seqres.full 2>&1
> -	[ -n "$rt_loop_dev" ] && _destroy_loop_device $rt_loop_dev
> -	rm -f $tmp.* $TEST_DIR/$seq.rtvol
> -}
> -
> -# Import common functions.
>  . ./common/filter
>  
> -# Note that we don't _require_realtime because we synthesize a rt volume
> -# below.
> -_require_scratch_nocheck
> -_require_no_large_scratch_dev
> -
> -echo "Create fake rt volume"
> -truncate -s 400m $TEST_DIR/$seq.rtvol
> -rt_loop_dev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
> +_require_realtime
> +_require_scratch
>  
>  echo "Format and mount 100m rt volume"
> -export USE_EXTERNAL=yes
> -export SCRATCH_RTDEV=$rtdev
>  _scratch_mkfs -r size=100m > $seqres.full
> -_try_scratch_mount || _notrun "Could not mount scratch with synthetic rt volume"
> +_scratch_mount
>  
> -# zoned file systems only support zoned size-rounded RT device sizes
> +# zoned file systems only support zone-size aligned RT device sizes
>  _require_xfs_scratch_non_zoned
>  
>  testdir=$SCRATCH_MNT/test-$seq
> @@ -58,7 +40,10 @@ echo "Create some files"
>  _pwrite_byte 0x61 0 1m $testdir/original >> $seqres.full
>  
>  echo "Grow fs"
> -$XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 |  _filter_growfs >> $seqres.full
> +# growfs expects sizes in FSB units
> +fsbsize=$(_get_block_size $SCRATCH_MNT)
> +$XFS_GROWFS_PROG -R $((400 * 1024 * 1024 / fsbsize)) $SCRATCH_MNT 2>&1 | \

Hrmm, I wonder if this test should check that SCRATCH_RTDEV is at least
400m?  But I guess the old code didn't check that the loop file doesn't
ENOSPC (which is another good reason to get rid of the fakery) so...

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> +	  _filter_growfs >> $seqres.full
>  _scratch_cycle_mount
>  
>  echo "Recheck 400m rt volume stats"
> @@ -73,8 +58,6 @@ echo "Check filesystem"
>  _check_scratch_fs
>  
>  _scratch_unmount
> -_destroy_loop_device $rt_loop_dev
> -unset rt_loop_dev
>  
>  # success, all done
>  status=0
> diff --git a/tests/xfs/521.out b/tests/xfs/521.out
> index 007ab92c6db2..afd18bb0dc99 100644
> --- a/tests/xfs/521.out
> +++ b/tests/xfs/521.out
> @@ -1,5 +1,4 @@
>  QA output created by 521
> -Create fake rt volume
>  Format and mount 100m rt volume
>  Check rt volume stats
>  Create some files
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers
  2025-12-10  5:46 ` [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers Christoph Hellwig
@ 2025-12-10 19:55   ` Darrick J. Wong
  0 siblings, 0 replies; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 19:55 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:54AM +0100, Christoph Hellwig wrote:
> This tests forces external devices to be disabled by calling mkfs.xfs
> directly and overriding SCRATCH_{LOG,RT}DEV, but the options specified in
> MKFS_OPTIONS might not work for this configuration.  Instead hard code
> the calls to xfs_db and don't modify the scratch device configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Oh yikes.  Yeah, this is more straightforward...
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  tests/xfs/424 | 41 ++++++++++++++++++-----------------------
>  1 file changed, 18 insertions(+), 23 deletions(-)
> 
> diff --git a/tests/xfs/424 b/tests/xfs/424
> index 6078d34897e7..61e9de375383 100755
> --- a/tests/xfs/424
> +++ b/tests/xfs/424
> @@ -25,17 +25,11 @@ filter_dbval()
>  	awk '{ print $4 }'
>  }
>  
> -# Import common functions.
>  . ./common/filter
>  
> -# Modify as appropriate
> -
> -# Since we have an open-coded mkfs call, disable the external devices and
> -# don't let the post-check fsck actually run since it'll trip over us not
> -# using the external devices.
> +# Since we have an open-coded mkfs call, don't let the post-check fsck run since
> +# it would trip over us not using the external devices.
>  _require_scratch_nocheck
> -export SCRATCH_LOGDEV=
> -export SCRATCH_RTDEV=
>  
>  echo "Silence is golden."
>  
> @@ -62,30 +56,31 @@ for SECTOR_SIZE in $sector_sizes; do
>  		grep -q 'finobt=1' && finobt_enabled=1
>  
>  	for TYPE in agf agi agfl sb; do
> -		DADDR=`_scratch_xfs_db -c "$TYPE" -c "daddr" | filter_dbval`
> -		_scratch_xfs_db -c "daddr $DADDR" -c "type $TYPE"
> +		DADDR=`$XFS_DB_PROG -c "$TYPE" -c "daddr" $SCRATCH_DEV |
> +			filter_dbval`
> +		$XFS_DB_PROG -c "daddr $DADDR" -c "type $TYPE" $SCRATCH_DEV
>  	done
>  
> -	DADDR=`_scratch_xfs_db -c "sb" -c "addr rootino" -c "daddr" |
> +	DADDR=`$XFS_DB_PROG -c "sb" -c "addr rootino" -c "daddr" $SCRATCH_DEV |
>  		filter_dbval`
> -	_scratch_xfs_db -c "daddr $DADDR" -c "type inode"
> -	DADDR=`_scratch_xfs_db -c "agf" -c "addr bnoroot" -c "daddr" |
> +	$XFS_DB_PROG -c "daddr $DADDR" -c "type inode" $SCRATCH_DEV
> +	DADDR=`$XFS_DB_PROG -c "agf" -c "addr bnoroot" -c "daddr" $SCRATCH_DEV |
>  		filter_dbval`
> -	_scratch_xfs_db -c "daddr $DADDR" -c "type bnobt"
> -	DADDR=`_scratch_xfs_db -c "agf" -c "addr cntroot" -c "daddr" |
> +	$XFS_DB_PROG -c "daddr $DADDR" -c "type bnobt" $SCRATCH_DEV
> +	DADDR=`$XFS_DB_PROG -c "agf" -c "addr cntroot" -c "daddr" $SCRATCH_DEV |
>  		filter_dbval`
> -	_scratch_xfs_db -c "daddr $DADDR" -c "type cntbt"
> -	DADDR=`_scratch_xfs_db -c "agi" -c "addr root" -c "daddr" |
> +	$XFS_DB_PROG -c "daddr $DADDR" -c "type cntbt" $SCRATCH_DEV
> +	DADDR=`$XFS_DB_PROG -c "agi" -c "addr root" -c "daddr" $SCRATCH_DEV |
>  		filter_dbval`
> -	_scratch_xfs_db -c "daddr $DADDR" -c "type inobt"
> +	$XFS_DB_PROG -c "daddr $DADDR" -c "type inobt" $SCRATCH_DEV
>  	if [ $finobt_enabled -eq 1 ]; then
> -		DADDR=`_scratch_xfs_db -c "agi" -c "addr free_root" -c "daddr" |
> -			filter_dbval`
> -		_scratch_xfs_db -c "daddr $DADDR" -c "type finobt"
> +		DADDR=`$XFS_DB_PROG -c "agi" -c "addr free_root" -c "daddr" $SCRATCH_DEV |
> +			 filter_dbval`
> +		$XFS_DB_PROG -c "daddr $DADDR" -c "type finobt" $SCRATCH_DEV
>  	fi
>  
> -	_scratch_xfs_db -c "daddr $DADDR" -c "type text"
> -	_scratch_xfs_db -c "daddr $DADDR" -c "type data"
> +	$XFS_DB_PROG -c "daddr $DADDR" -c "type text" $SCRATCH_DEV
> +	$XFS_DB_PROG -c "daddr $DADDR" -c "type data" $SCRATCH_DEV
>  done
>  
>  # success, all done
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers
  2025-12-10  5:46 ` [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers Christoph Hellwig
@ 2025-12-10 20:02   ` Darrick J. Wong
  2025-12-11  5:00     ` Christoph Hellwig
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 20:02 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:53AM +0100, Christoph Hellwig wrote:
> This tests creates loop-based data and rt devices for testing.  Don't
> override SCRATCH_{,RT}DEV and don't use the helpers based on it because
> the options specified in MKFS_OPTIONS might not work for this
> configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/xfs/185 | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/xfs/185 b/tests/xfs/185
> index 7aceb383ce46..84139be8e66e 100755
> --- a/tests/xfs/185
> +++ b/tests/xfs/185
<snip>
> @@ -64,16 +63,8 @@ rtminor=$(stat -c '%T' "$rtloop")
>  test $ddmajor -le $rtmajor || \
>  	_notrun "Data loopdev minor $ddminor larger than rt minor $rtminor"
>  
> -# Inject our custom-built devices as an rt-capable scratch device.
> -# We avoid touching "require_scratch" so that post-test fsck will not try to
> -# run on our synthesized scratch device.
> -old_use_external="$USE_EXTERNAL"
> -USE_EXTERNAL=yes
> -SCRATCH_RTDEV="$rtloop"
> -SCRATCH_DEV="$ddloop"
> -
> -_scratch_mkfs >> $seqres.full
> -_try_scratch_mount >> $seqres.full || \
> +$MKFS_XFS_PROG -r rtdev=$rtloop $ddloop  >> $seqres.full
> +mount -o rtdev=$rtloop $ddloop $SCRATCH_MNT >> $seqres.full || \
>  	_notrun "mount with injected rt device failed"

What happens if SCRATCH_LOGDEV is set?  I guess we ignore it, and
everything is good?  I suppose the logdev configuration isn't really
relevant here anyway.

If the answers are 'nothing' and 'yes' then
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

>  # Create a file that we'll use to seed fsmap entries for the rt device,
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV
  2025-12-10  5:46 ` [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV Christoph Hellwig
@ 2025-12-10 20:05   ` Darrick J. Wong
  0 siblings, 0 replies; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 20:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:52AM +0100, Christoph Hellwig wrote:
> This tests wants to test various difference device configurations,
> and does so by overriding SCRATCH_{,LOG,RT}DEV.  This has two downside:
> 
>  1) the actual SCRATCH_{,LOG,RT}DEV configuration is still injected by
>     default, thus making the test dependent on that configuration
>  2) the MKFS_OPTIONS might not actually be compatible with the
>     configuration created
> 
> Fix this by open coding the mkfs, db, admin and repair calls and always
> run them on the specific configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Interesting solution to that...
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  tests/xfs/157 | 104 +++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 78 insertions(+), 26 deletions(-)
> 
> diff --git a/tests/xfs/157 b/tests/xfs/157
> index e102a5a10abe..31f05db25724 100755
> --- a/tests/xfs/157
> +++ b/tests/xfs/157
> @@ -50,53 +50,105 @@ fake_rtfile=$TEST_DIR/$seq.scratch.rt
>  rm -f $fake_rtfile
>  truncate -s $fs_size $fake_rtfile
>  
> -# Save the original variables
> -orig_ddev=$SCRATCH_DEV
> -orig_external=$USE_EXTERNAL
> -orig_logdev=$SCRATCH_LOGDEV
> -orig_rtdev=$SCRATCH_RTDEV
> -
>  scenario() {
>  	echo "$@" | tee -a $seqres.full
>  
> -	SCRATCH_DEV=$orig_ddev
> -	USE_EXTERNAL=$orig_external
> -	SCRATCH_LOGDEV=$orig_logdev
> -	SCRATCH_RTDEV=$orig_rtdev
> +	dev=$SCRATCH_DEV
> +	logdev=
> +	rtdev=
> +}
> +
> +_fake_mkfs()
> +{
> +	OPTIONS="$*"
> +	if [ -n "$logdev" ]; then
> +		OPTIONS="$OPTIONS -l logdev=$logdev"
> +	fi
> +	if [ -n "$rtdev" ]; then
> +		OPTIONS="$OPTIONS -r rtdev=$rtdev"
> +	fi
> +	$MKFS_XFS_PROG -f $OPTIONS $dev || _fail "mkfs failed"
> +}
> +
> +_fake_xfs_db_options()
> +{
> +	OPTIONS=""
> +	if [ ! -z "$logdev" ]; then
> +		OPTIONS="-l $logdev"
> +	fi
> +	if [ ! -z "$rtdev" ]; then
> +		if [ $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev']; then
> +			OPTIONS="$OPTIONS -R $rtdev"
> +		fi
> +	fi
> +	echo $OPTIONS $* $dev
> +}
> +
> +_fake_xfs_db()
> +{
> +	$XFS_DB_PROG "$@" $(_fake_xfs_db_options)
> +}
> +
> +_fake_xfs_admin()
> +{
> +	local options=("$dev")
> +	local rt_opts=()
> +	if [ -n "$logdev" ]; then
> +		options+=("$logdev")
> +	fi
> +	if [ -n "$rtdev" ]; then
> +		$XFS_ADMIN_PROG --help 2>&1 | grep -q 'rtdev' || \
> +			_notrun 'xfs_admin does not support rt devices'
> +		rt_opts+=(-r "$rtdev")
> +	fi
> +
> +	# xfs_admin in xfsprogs 5.11 has a bug where an external log device
> +	# forces xfs_db to be invoked, potentially with zero command arguments.
> +	# When this happens, xfs_db will wait for input on stdin, which causes
> +	# fstests to hang.  Since xfs_admin is not an interactive tool, we
> +	# can redirect stdin from /dev/null to prevent this issue.
> +	$XFS_ADMIN_PROG "${rt_opts[@]}" "$@" "${options[@]}" < /dev/null
> +}
> +
> +
> +_fake_xfs_repair()
> +{
> +	OPTIONS=""
> +	if [ -n "$logdev" ]; then
> +		OPTIONS="-l $logdev"
> +	fi
> +	if [ -n "$rtdev" ]; then
> +		OPTIONS="$OPTIONS -r $rtdev"
> +	fi
> +	$XFS_REPAIR_PROG $OPTIONS $* $dev
>  }
>  
>  check_label() {
> -	_scratch_mkfs_sized "$fs_size" "" -L oldlabel >> $seqres.full 2>&1
> -	_scratch_xfs_db -c label
> -	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> -	_scratch_xfs_db -c label
> -	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +	_fake_mkfs -L oldlabel >> $seqres.full 2>&1
> +	_fake_xfs_db -c label
> +	_fake_xfs_admin -L newlabel "$@" >> $seqres.full
> +	_fake_xfs_db -c label
> +	_fake_xfs_repair -n &>> $seqres.full || echo "Check failed?"
>  }
>  
>  scenario "S1: Check that label setting with file image"
> -SCRATCH_DEV=$fake_datafile
> +dev=$fake_datafile
>  check_label -f
>  
>  scenario "S2: Check that setting with logdev works"
> -USE_EXTERNAL=yes
> -SCRATCH_LOGDEV=$fake_logfile
> +logdev=$fake_logfile
>  check_label
>  
>  scenario "S3: Check that setting with rtdev works"
> -USE_EXTERNAL=yes
> -SCRATCH_RTDEV=$fake_rtfile
> +rtdev=$fake_rtfile
>  check_label
>  
>  scenario "S4: Check that setting with rtdev + logdev works"
> -USE_EXTERNAL=yes
> -SCRATCH_LOGDEV=$fake_logfile
> -SCRATCH_RTDEV=$fake_rtfile
> +logdev=$fake_logfile
> +rtdev=$fake_rtfile
>  check_label
>  
>  scenario "S5: Check that setting with nortdev + nologdev works"
> -USE_EXTERNAL=
> -SCRATCH_LOGDEV=
> -SCRATCH_RTDEV=
>  check_label
>  
>  scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 12/12] xfs/650:  require a real SCRATCH_RTDEV
  2025-12-10 19:45   ` Darrick J. Wong
@ 2025-12-10 22:50     ` Darrick J. Wong
  2025-12-11  4:54       ` Christoph Hellwig
  0 siblings, 1 reply; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 22:50 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 11:45:49AM -0800, Darrick J. Wong wrote:
> On Wed, Dec 10, 2025 at 06:46:58AM +0100, Christoph Hellwig wrote:
> > Require a real SCRATCH_RTDEV instead of faking one up using a loop
> > device, as otherwise the options specified in MKFS_OPTIONS might
> > not actually work the configuration.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  tests/xfs/650 | 63 +++++----------------------------------------------
> 
> Er... what test is xfs/650?  There isn't one in for-next.

Aha, I missed that an earlier patch created it. :(

The one downside to not injecting a rt device here is that now the only
testing for the actual bug is if you happen to have rt enabled.  That
used to be a concern of mine, but maybe between you, me, Meta, and the
kdevops folks there's enough now.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> 
> >  1 file changed, 6 insertions(+), 57 deletions(-)
> > 
> > diff --git a/tests/xfs/650 b/tests/xfs/650
> > index d8f70539665f..418a1e7aae7c 100755
> > --- a/tests/xfs/650
> > +++ b/tests/xfs/650
> > @@ -9,21 +9,11 @@
> >  # bunmapi"). On XFS without the fixes, truncate will hang forever.
> >  #
> >  . ./common/preamble
> > -_begin_fstest auto prealloc preallocrw
> > -
> > -# Override the default cleanup function.
> > -_cleanup()
> > -{
> > -	_scratch_unmount &>/dev/null
> > -	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
> > -	cd /
> > -	rm -f $tmp.*
> > -	rm -f "$TEST_DIR/$seq"
> > -}
> > +_begin_fstest auto prealloc preallocrw realtime
> >  
> >  . ./common/filter
> >  
> > -_require_scratch_nocheck
> > +_require_realtime
> >  _require_xfs_io_command "falloc"
> >  
> >  maxextlen=$((0x1fffff))
> > @@ -31,51 +21,11 @@ bs=4096
> >  rextsize=4
> >  filesz=$(((maxextlen + 1) * bs))
> >  
> > -must_disable_feature() {
> > -	local feat="$1"
> > -
> > -	# If mkfs doesn't know about the feature, we don't need to disable it
> > -	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
> > -
> > -	# If turning the feature on works, we don't need to disable it
> > -	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
> > -		> /dev/null 2>&1 && return 1
> > -
> > -	# Otherwise mkfs knows of the feature and formatting with it failed,
> > -	# so we do need to mask it.
> > -	return 0
> > -}
> > -
> > -extra_options=""
> > -# Set up the realtime device to reproduce the bug.
> > +_scratch_mkfs \
> > +	-d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1 \
> > +	-r extsize=$((bs * rextsize)) \
> > +	>>$seqres.full 2>&1
> >  
> > -# If we don't have a realtime device, set up a loop device on the test
> > -# filesystem.
> > -if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
> > -	_require_test
> > -	loopsz="$((filesz + (1 << 26)))"
> > -	_require_fs_space "$TEST_DIR" $((loopsz / 1024))
> > -	$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
> > -	loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
> > -	USE_EXTERNAL=yes
> > -	SCRATCH_RTDEV="$loop_dev"
> > -	disabled_features=()
> > -
> > -	# disable reflink if not supported by realtime devices
> > -	must_disable_feature reflink &&
> > -		disabled_features=(-m reflink=0)
> > -
> > -	# disable rmap if not supported by realtime devices
> > -	must_disable_feature rmapbt &&
> > -		disabled_features+=(-m rmapbt=0)
> > -fi
> > -extra_options="$extra_options -r extsize=$((bs * rextsize))"
> > -extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
> > -
> > -_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
> > -_try_scratch_mount >>$seqres.full 2>&1 || \
> > -	_notrun "mount failed, kernel doesn't support realtime?"
> > -_scratch_unmount
> >  _scratch_mount
> >  _require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
> >  
> > @@ -108,7 +58,6 @@ $XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
> >  # Truncate the extents.
> >  $XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
> >  
> > -# We need to do this before the loop device gets torn down.
> >  _scratch_unmount
> >  _check_scratch_fs
> >  
> > -- 
> > 2.47.3
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 05/12] generic/590: split XFS RT specific bits out
  2025-12-10  5:46 ` [PATCH 05/12] generic/590: split XFS RT specific bits out Christoph Hellwig
@ 2025-12-10 22:51   ` Darrick J. Wong
  0 siblings, 0 replies; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 22:51 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:51AM +0100, Christoph Hellwig wrote:
> Currently generic/590 runs a very different test on XFS that creates
> a lot device and so on.  Split that out into a new XFS-specific test,
> and let generic/590 always run using the file system parameter specified
> in the config even for XFS.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Yeah, that sounds like a good idea.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  tests/generic/590 |  68 ++-------------------------
>  tests/xfs/650     | 117 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/650.out |   2 +
>  3 files changed, 123 insertions(+), 64 deletions(-)
>  create mode 100755 tests/xfs/650
>  create mode 100644 tests/xfs/650.out
> 
> diff --git a/tests/generic/590 b/tests/generic/590
> index ba1337a856f1..54c26f2ae5ed 100755
> --- a/tests/generic/590
> +++ b/tests/generic/590
> @@ -4,27 +4,15 @@
>  #
>  # FS QA Test 590
>  #
> -# Test commit 0c4da70c83d4 ("xfs: fix realtime file data space leak") and
> -# 69ffe5960df1 ("xfs: don't check for AG deadlock for realtime files in
> -# bunmapi"). On XFS without the fixes, truncate will hang forever. On other
> -# filesystems, this just tests writing into big fallocates.
> +# Tests writing into big fallocates.
> +#
> +# Based on an XFS RT subvolume specific test now split into xfs/650.
>  #
>  . ./common/preamble
>  _begin_fstest auto prealloc preallocrw
>  
> -# Override the default cleanup function.
> -_cleanup()
> -{
> -	_scratch_unmount &>/dev/null
> -	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
> -	cd /
> -	rm -f $tmp.*
> -	rm -f "$TEST_DIR/$seq"
> -}
> -
>  . ./common/filter
>  
> -_require_scratch_nocheck
>  _require_xfs_io_command "falloc"
>  
>  maxextlen=$((0x1fffff))
> @@ -32,54 +20,7 @@ bs=4096
>  rextsize=4
>  filesz=$(((maxextlen + 1) * bs))
>  
> -must_disable_feature() {
> -	local feat="$1"
> -
> -	# If mkfs doesn't know about the feature, we don't need to disable it
> -	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
> -
> -	# If turning the feature on works, we don't need to disable it
> -	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
> -		> /dev/null 2>&1 && return 1
> -
> -	# Otherwise mkfs knows of the feature and formatting with it failed,
> -	# so we do need to mask it.
> -	return 0
> -}
> -
> -extra_options=""
> -# If we're testing XFS, set up the realtime device to reproduce the bug.
> -if [[ $FSTYP = xfs ]]; then
> -	# If we don't have a realtime device, set up a loop device on the test
> -	# filesystem.
> -	if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
> -		_require_test
> -		loopsz="$((filesz + (1 << 26)))"
> -		_require_fs_space "$TEST_DIR" $((loopsz / 1024))
> -		$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
> -		loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
> -		USE_EXTERNAL=yes
> -		SCRATCH_RTDEV="$loop_dev"
> -		disabled_features=()
> -
> -		# disable reflink if not supported by realtime devices
> -		must_disable_feature reflink &&
> -			disabled_features=(-m reflink=0)
> -
> -		# disable rmap if not supported by realtime devices
> -		must_disable_feature rmapbt &&
> -			disabled_features+=(-m rmapbt=0)
> -	fi
> -	extra_options="$extra_options -r extsize=$((bs * rextsize))"
> -	extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
> -
> -	_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
> -	_try_scratch_mount >>$seqres.full 2>&1 || \
> -		_notrun "mount failed, kernel doesn't support realtime?"
> -	_scratch_unmount
> -else
> -	_scratch_mkfs $extra_options >>$seqres.full 2>&1
> -fi
> +_scratch_mkfs >>$seqres.full 2>&1
>  _scratch_mount
>  _require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
>  
> @@ -112,7 +53,6 @@ $XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
>  # Truncate the extents.
>  $XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
>  
> -# We need to do this before the loop device gets torn down.
>  _scratch_unmount
>  _check_scratch_fs
>  
> diff --git a/tests/xfs/650 b/tests/xfs/650
> new file mode 100755
> index 000000000000..d8f70539665f
> --- /dev/null
> +++ b/tests/xfs/650
> @@ -0,0 +1,117 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2019 Facebook.  All Rights Reserved.
> +#
> +# FS QA Test 650
> +#
> +# Test commit 0c4da70c83d4 ("xfs: fix realtime file data space leak") and
> +# 69ffe5960df1 ("xfs: don't check for AG deadlock for realtime files in
> +# bunmapi"). On XFS without the fixes, truncate will hang forever.
> +#
> +. ./common/preamble
> +_begin_fstest auto prealloc preallocrw
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +	_scratch_unmount &>/dev/null
> +	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
> +	cd /
> +	rm -f $tmp.*
> +	rm -f "$TEST_DIR/$seq"
> +}
> +
> +. ./common/filter
> +
> +_require_scratch_nocheck
> +_require_xfs_io_command "falloc"
> +
> +maxextlen=$((0x1fffff))
> +bs=4096
> +rextsize=4
> +filesz=$(((maxextlen + 1) * bs))
> +
> +must_disable_feature() {
> +	local feat="$1"
> +
> +	# If mkfs doesn't know about the feature, we don't need to disable it
> +	$MKFS_XFS_PROG --help 2>&1 | grep -q "${feat}=0" || return 1
> +
> +	# If turning the feature on works, we don't need to disable it
> +	_scratch_mkfs_xfs_supported -m "${feat}=1" "${disabled_features[@]}" \
> +		> /dev/null 2>&1 && return 1
> +
> +	# Otherwise mkfs knows of the feature and formatting with it failed,
> +	# so we do need to mask it.
> +	return 0
> +}
> +
> +extra_options=""
> +# Set up the realtime device to reproduce the bug.
> +
> +# If we don't have a realtime device, set up a loop device on the test
> +# filesystem.
> +if [[ $USE_EXTERNAL != yes || -z $SCRATCH_RTDEV ]]; then
> +	_require_test
> +	loopsz="$((filesz + (1 << 26)))"
> +	_require_fs_space "$TEST_DIR" $((loopsz / 1024))
> +	$XFS_IO_PROG -c "truncate $loopsz" -f "$TEST_DIR/$seq"
> +	loop_dev="$(_create_loop_device "$TEST_DIR/$seq")"
> +	USE_EXTERNAL=yes
> +	SCRATCH_RTDEV="$loop_dev"
> +	disabled_features=()
> +
> +	# disable reflink if not supported by realtime devices
> +	must_disable_feature reflink &&
> +		disabled_features=(-m reflink=0)
> +
> +	# disable rmap if not supported by realtime devices
> +	must_disable_feature rmapbt &&
> +		disabled_features+=(-m rmapbt=0)
> +fi
> +extra_options="$extra_options -r extsize=$((bs * rextsize))"
> +extra_options="$extra_options -d agsize=$(((maxextlen + 1) * bs / 2)),rtinherit=1"
> +
> +_scratch_mkfs $extra_options "${disabled_features[@]}" >>$seqres.full 2>&1
> +_try_scratch_mount >>$seqres.full 2>&1 || \
> +	_notrun "mount failed, kernel doesn't support realtime?"
> +_scratch_unmount
> +_scratch_mount
> +_require_fs_space "$SCRATCH_MNT" $((filesz / 1024))
> +
> +# Allocate maxextlen + 1 blocks. As long as the allocator does something sane,
> +# we should end up with two extents that look something like:
> +#
> +# u3.bmx[0-1] = [startoff,startblock,blockcount,extentflag]
> +# 0:[0,0,2097148,1]
> +# 1:[2097148,2097148,4,1]
> +#
> +# Extent 0 has blockcount = ALIGN_DOWN(maxextlen, rextsize). Extent 1 is
> +# adjacent and has blockcount = rextsize. Both are unwritten.
> +$XFS_IO_PROG -c "falloc 0 $filesz" -c fsync -f "$SCRATCH_MNT/file"
> +
> +# Write extent 0 + one block of extent 1. Our extents should end up like so:
> +#
> +# u3.bmx[0-1] = [startoff,startblock,blockcount,extentflag]
> +# 0:[0,0,2097149,0]
> +# 1:[2097149,2097149,3,1]
> +#
> +# Extent 0 is written and has blockcount = ALIGN_DOWN(maxextlen, rextsize) + 1,
> +# Extent 1 is adjacent, unwritten, and has blockcount = rextsize - 1 and
> +# startblock % rextsize = 1.
> +#
> +# The -b is just to speed things up (doing GBs of I/O in 4k chunks kind of
> +# sucks).
> +$XFS_IO_PROG -c "pwrite -b 1M -W 0 $(((maxextlen + 2 - rextsize) * bs))" \
> +	"$SCRATCH_MNT/file" >> "$seqres.full"
> +
> +# Truncate the extents.
> +$XFS_IO_PROG -c "truncate 0" -c fsync "$SCRATCH_MNT/file"
> +
> +# We need to do this before the loop device gets torn down.
> +_scratch_unmount
> +_check_scratch_fs
> +
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/xfs/650.out b/tests/xfs/650.out
> new file mode 100644
> index 000000000000..d7a3e4b63483
> --- /dev/null
> +++ b/tests/xfs/650.out
> @@ -0,0 +1,2 @@
> +QA output created by 650
> +Silence is golden
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 03/12] common: add a _check_dev_fs helper
  2025-12-10  5:46 ` [PATCH 03/12] common: add a _check_dev_fs helper Christoph Hellwig
@ 2025-12-10 23:24   ` Darrick J. Wong
  0 siblings, 0 replies; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 23:24 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:49AM +0100, Christoph Hellwig wrote:
> Add a helper to run the file system checker for a given device, and stop
> overloading _check_scratch_fs with the optional device argument that
> creates complication around scratch RT and log devices.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> Note: dmthin should probably do the same as dmflakey does, but all
> my attempts never got the new SCRATCH_DEV value propagated out of
> _dmthin_init.  Maybe someone smarted than me wants to give it another
> try.

One of those dm wrappers has that weird behavior that it has to be
`source'able from a shell invoked by a subprocess.  That's caused me
headaches in the past.

Nevertheless, these changes look ok so
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D


>  common/dmthin     |  6 +++++-
>  common/rc         | 21 +++++++++++++++++----
>  tests/btrfs/176   |  4 ++--
>  tests/generic/648 |  2 +-
>  tests/xfs/601     |  2 +-
>  5 files changed, 26 insertions(+), 9 deletions(-)
> 
> diff --git a/common/dmthin b/common/dmthin
> index a1e1fb8763c0..3bea828d0375 100644
> --- a/common/dmthin
> +++ b/common/dmthin
> @@ -33,7 +33,11 @@ _dmthin_cleanup()
>  _dmthin_check_fs()
>  {
>  	_unmount $SCRATCH_MNT > /dev/null 2>&1
> -	_check_scratch_fs $DMTHIN_VOL_DEV
> +	OLD_SCRATCH_DEV=$SCRATCH_DEV
> +	SCRATCH_DEV=$DMTHIN_VOL_DEV
> +	_check_scratch_fs
> +	SCRATCH_DEV=$OLD_SCRATCH_DEV
> +	unset OLD_SCRATCH_DEV
>  }
>  
>  # Set up a dm-thin device on $SCRATCH_DEV
> diff --git a/common/rc b/common/rc
> index c3cdc220a29b..8618f77a00b5 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -3692,14 +3692,14 @@ _check_test_fs()
>      esac
>  }
>  
> -_check_scratch_fs()
> +# check the file system passed in as $1
> +_check_dev_fs()
>  {
> -    local device=$SCRATCH_DEV
> -    [ $# -eq 1 ] && device=$1
> +    local device=$1
>  
>      case $FSTYP in
>      xfs)
> -	_check_xfs_scratch_fs $device
> +	_check_xfs_filesystem $device "none" "none"
>  	;;
>      udf)
>  	_check_udf_filesystem $device $udf_fsize
> @@ -3751,6 +3751,19 @@ _check_scratch_fs()
>      esac
>  }
>  
> +# check the scratch file system
> +_check_scratch_fs()
> +{
> +	case $FSTYP in
> +	xfs)
> +		_check_xfs_scratch_fs $SCRATCH_DEV
> +		;;
> +	*)
> +		_check_dev_fs $SCRATCH_DEV
> +		;;
> +	esac
> +}
> +
>  _full_fstyp_details()
>  {
>       [ -z "$FSTYP" ] && FSTYP=xfs
> diff --git a/tests/btrfs/176 b/tests/btrfs/176
> index 86796c8814a0..f2619bdd8e44 100755
> --- a/tests/btrfs/176
> +++ b/tests/btrfs/176
> @@ -37,7 +37,7 @@ swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
>  # Deleting device 1 should work again after swapoff.
>  $BTRFS_UTIL_PROG device delete "$scratch_dev1" "$SCRATCH_MNT"
>  _scratch_unmount
> -_check_scratch_fs "$scratch_dev2"
> +_check_dev_fs "$scratch_dev2"
>  
>  echo "Replace device"
>  _scratch_mkfs >> $seqres.full 2>&1
> @@ -55,7 +55,7 @@ swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
>  $BTRFS_UTIL_PROG replace start -fB "$scratch_dev1" "$scratch_dev2" "$SCRATCH_MNT" \
>  	>> $seqres.full
>  _scratch_unmount
> -_check_scratch_fs "$scratch_dev2"
> +_check_dev_fs "$scratch_dev2"
>  
>  # success, all done
>  status=0
> diff --git a/tests/generic/648 b/tests/generic/648
> index 7473c9d33746..1bba78f062cf 100755
> --- a/tests/generic/648
> +++ b/tests/generic/648
> @@ -133,7 +133,7 @@ if [ -f "$loopimg" ]; then
>  		_metadump_dev $DMERROR_DEV $seqres.scratch.final.md
>  		echo "final scratch mount failed"
>  	fi
> -	SCRATCH_RTDEV= SCRATCH_LOGDEV= _check_scratch_fs $loopimg
> +	_check_dev_fs $loopimg
>  fi
>  
>  # success, all done; let the test harness check the scratch fs
> diff --git a/tests/xfs/601 b/tests/xfs/601
> index df382402b958..44911ea389a7 100755
> --- a/tests/xfs/601
> +++ b/tests/xfs/601
> @@ -39,7 +39,7 @@ copy_file=$testdir/copy.img
>  
>  echo copy
>  $XFS_COPY_PROG $SCRATCH_DEV $copy_file >> $seqres.full
> -_check_scratch_fs $copy_file
> +_check_dev_fs $copy_file
>  
>  echo recopy
>  $XFS_COPY_PROG $copy_file $SCRATCH_DEV >> $seqres.full
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 04/12] ext4/032: use _check_dev_fs
  2025-12-10  5:46 ` [PATCH 04/12] ext4/032: use _check_dev_fs Christoph Hellwig
@ 2025-12-10 23:24   ` Darrick J. Wong
  0 siblings, 0 replies; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-10 23:24 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Wed, Dec 10, 2025 at 06:46:50AM +0100, Christoph Hellwig wrote:
> _check_dev_fs is the new designated helper to check file systems on
> arbitrary devices, use that instead of _check_generic_filesystem, which
> is just an implementation detail.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks reasonable to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  tests/ext4/032 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/ext4/032 b/tests/ext4/032
> index 690fcf066c11..043ae4f53505 100755
> --- a/tests/ext4/032
> +++ b/tests/ext4/032
> @@ -66,7 +66,7 @@ ext4_online_resize()
>  	$UMOUNT_PROG ${IMG_MNT}
>  
>  	echo "+++ check fs" | tee -a $seqres.full
> -	_check_generic_filesystem $LOOP_DEVICE >> $seqres.full 2>&1 || \
> +	_check_dev_fs $LOOP_DEVICE >> $seqres.full 2>&1 || \
>  		_fail "fsck should not fail"
>  	_destroy_loop_device $LOOP_DEVICE && LOOP_DEVICE=
>  }
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 02/12] ext4/006: call e2fsck directly
  2025-12-10 19:32   ` Darrick J. Wong
@ 2025-12-11  4:52     ` Christoph Hellwig
  0 siblings, 0 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-11  4:52 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Zorro Lang, Anand Jain, Filipe Manana, fstests,
	linux-ext4, linux-xfs

On Wed, Dec 10, 2025 at 11:32:26AM -0800, Darrick J. Wong wrote:
> On Wed, Dec 10, 2025 at 06:46:48AM +0100, Christoph Hellwig wrote:
> > _check_scratch_fs takes an optional device name, but no optional
> > arguments.  Call e2fsck directly for this extN-specific test instead.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  tests/ext4/006 | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tests/ext4/006 b/tests/ext4/006
> > index 2ece22a4bd1e..07dcf356b0bc 100755
> > --- a/tests/ext4/006
> > +++ b/tests/ext4/006
> > @@ -44,7 +44,7 @@ repair_scratch() {
> >  	res=$?
> >  	if [ "${res}" -eq 0 ]; then
> >  		echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
> > -		_check_scratch_fs -n >> "${FSCK_LOG}" 2>&1
> > +		e2fsck -n >> "${FSCK_LOG}" 2>&1
> 
> Doesn't this need a device name?  e.g. e2fsck -n $SCRATCH_DEV ?

Yes.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 12/12] xfs/650:  require a real SCRATCH_RTDEV
  2025-12-10 22:50     ` Darrick J. Wong
@ 2025-12-11  4:54       ` Christoph Hellwig
  0 siblings, 0 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-11  4:54 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Zorro Lang, Anand Jain, Filipe Manana, fstests,
	linux-ext4, linux-xfs

On Wed, Dec 10, 2025 at 02:50:43PM -0800, Darrick J. Wong wrote:
> Aha, I missed that an earlier patch created it. :(
> 
> The one downside to not injecting a rt device here is that now the only
> testing for the actual bug is if you happen to have rt enabled.  That
> used to be a concern of mine, but maybe between you, me, Meta, and the
> kdevops folks there's enough now.

I guess that was the reason to create it, but on the other hand injecting
new devices is a mess.  One option would be to totally inject the devices,
but that requires a lot of boilerplate as done in the labelling test.

So I think the concept of "you need a RT device to test RT specific
code" should be ok, even if your concern is real.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 11/12] xfs/530: require a real SCRATCH_RTDEV
  2025-12-10 19:49   ` Darrick J. Wong
@ 2025-12-11  4:55     ` Christoph Hellwig
  2025-12-12 20:00       ` Darrick J. Wong
  0 siblings, 1 reply; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-11  4:55 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Zorro Lang, Anand Jain, Filipe Manana, fstests,
	linux-ext4, linux-xfs

On Wed, Dec 10, 2025 at 11:49:48AM -0800, Darrick J. Wong wrote:
> > +$XFS_GROWFS_PROG -R $((rtdevsize / fsbsize)) $SCRATCH_MNT \
> 
> Why doesn't growfs -r still work here?

growfs -r still works, but the golden output expects a specific size.
So if we want to use use that we'd need to drop the gold output checking
for a specific new capacity.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 10/12] xfs/528: require a real SCRATCH_RTDEV
  2025-12-10 19:52   ` Darrick J. Wong
@ 2025-12-11  4:57     ` Christoph Hellwig
  0 siblings, 0 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-11  4:57 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Zorro Lang, Anand Jain, Filipe Manana, fstests,
	linux-ext4, linux-xfs

On Wed, Dec 10, 2025 at 11:52:20AM -0800, Darrick J. Wong wrote:
> >  	log "Format rtextsize=$rextsize"
> > -	_scratch_unmount
> >  	_scratch_mkfs -r extsize=$rextsize >> $seqres.full
> >  	_try_scratch_mount || \
> >  		_notrun "Could not mount rextsize=$rextsize with synthetic rt volume"
> > @@ -150,30 +138,16 @@ test_ops() {
> >  	check_file $SCRATCH_MNT/lpunch
> >  
> >  	log "Check everything, rextsize=$rextsize"
> > +	_scratch_unmount
> >  	_check_scratch_fs
> 
> Why does _scratch_unmount move to this part of the loop?  Unmounting the
> filesystem means that _check_xfs_filesystem won't run xfs_scrub on it.
> 
> (Everything else looks ok.)

Because it now it also is mounted inside the loop and not before the
loop, so unmounting it in the beginning won't work.  But I'll sort out
the order vs _check_scratch_fs.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV
  2025-12-10 19:54   ` Darrick J. Wong
@ 2025-12-11  4:58     ` Christoph Hellwig
  0 siblings, 0 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-11  4:58 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Zorro Lang, Anand Jain, Filipe Manana, fstests,
	linux-ext4, linux-xfs

On Wed, Dec 10, 2025 at 11:54:27AM -0800, Darrick J. Wong wrote:
> 
> Hrmm, I wonder if this test should check that SCRATCH_RTDEV is at least
> 400m?  But I guess the old code didn't check that the loop file doesn't
> ENOSPC (which is another good reason to get rid of the fakery) so...

Yeah, I didn't add a new check.  But adding a _require_scratch_size
shouldn't hurt, so I'll look into that for the next version.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers
  2025-12-10 20:02   ` Darrick J. Wong
@ 2025-12-11  5:00     ` Christoph Hellwig
  0 siblings, 0 replies; 32+ messages in thread
From: Christoph Hellwig @ 2025-12-11  5:00 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Zorro Lang, Anand Jain, Filipe Manana, fstests,
	linux-ext4, linux-xfs

On Wed, Dec 10, 2025 at 12:02:48PM -0800, Darrick J. Wong wrote:
> > -_scratch_mkfs >> $seqres.full
> > -_try_scratch_mount >> $seqres.full || \
> > +$MKFS_XFS_PROG -r rtdev=$rtloop $ddloop  >> $seqres.full
> > +mount -o rtdev=$rtloop $ddloop $SCRATCH_MNT >> $seqres.full || \
> >  	_notrun "mount with injected rt device failed"
> 
> What happens if SCRATCH_LOGDEV is set?  I guess we ignore it, and
> everything is good?  I suppose the logdev configuration isn't really
> relevant here anyway.
> 
> If the answers are 'nothing' and 'yes' then

Yes, this now ignores the SCRATCH_* config entirely.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 11/12] xfs/530: require a real SCRATCH_RTDEV
  2025-12-11  4:55     ` Christoph Hellwig
@ 2025-12-12 20:00       ` Darrick J. Wong
  0 siblings, 0 replies; 32+ messages in thread
From: Darrick J. Wong @ 2025-12-12 20:00 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Zorro Lang, Anand Jain, Filipe Manana, fstests, linux-ext4,
	linux-xfs

On Thu, Dec 11, 2025 at 05:55:04AM +0100, Christoph Hellwig wrote:
> On Wed, Dec 10, 2025 at 11:49:48AM -0800, Darrick J. Wong wrote:
> > > +$XFS_GROWFS_PROG -R $((rtdevsize / fsbsize)) $SCRATCH_MNT \
> > 
> > Why doesn't growfs -r still work here?
> 
> growfs -r still works, but the golden output expects a specific size.
> So if we want to use use that we'd need to drop the gold output checking
> for a specific new capacity.

Got it, thanks.

--D

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2025-12-12 20:00 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
2025-12-10  5:46 ` [PATCH 01/12] dmflakey: override SCRATCH_DEV in _init_flakey Christoph Hellwig
2025-12-10  5:46 ` [PATCH 02/12] ext4/006: call e2fsck directly Christoph Hellwig
2025-12-10 19:32   ` Darrick J. Wong
2025-12-11  4:52     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 03/12] common: add a _check_dev_fs helper Christoph Hellwig
2025-12-10 23:24   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 04/12] ext4/032: use _check_dev_fs Christoph Hellwig
2025-12-10 23:24   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 05/12] generic/590: split XFS RT specific bits out Christoph Hellwig
2025-12-10 22:51   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV Christoph Hellwig
2025-12-10 20:05   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers Christoph Hellwig
2025-12-10 20:02   ` Darrick J. Wong
2025-12-11  5:00     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers Christoph Hellwig
2025-12-10 19:55   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV Christoph Hellwig
2025-12-10 19:54   ` Darrick J. Wong
2025-12-11  4:58     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 10/12] xfs/528: " Christoph Hellwig
2025-12-10 19:52   ` Darrick J. Wong
2025-12-11  4:57     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 11/12] xfs/530: " Christoph Hellwig
2025-12-10 19:49   ` Darrick J. Wong
2025-12-11  4:55     ` Christoph Hellwig
2025-12-12 20:00       ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 12/12] xfs/650: " Christoph Hellwig
2025-12-10 19:45   ` Darrick J. Wong
2025-12-10 22:50     ` Darrick J. Wong
2025-12-11  4:54       ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).