Skip to contentSkip to conversation

common/config: export TEST_DEV for mkfs.xfs

PATCH In review David Disseldorp 4 participants 10 messages Apr 11, 2024 – Apr 29, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 common/config: export TEST_DEV for mkfs.xfs

As of xfsprogs commit 6e0ed3d1 ("mkfs: stop allowing tiny filesystems") attempts to create XFS filesystems sized under 300M fail, unless TEST_DIR, TEST_DEV and QA_CHECK_FS environment variables are exported (or a --unsupported mkfs parameter is provided).

TEST_DIR and QA_CHECK_FS are already exported, while TEST_DEV may only be locally set if provided via e.g. configs/$HOSTNAME.config. Explicitly export TEST_DEV to ensure that tests which call _scratch_mkfs_sized() with an fssize under 300M run normally.

---
 common/config | 3 +++
 1 file changed, 3 insertions(+)
common/config +3 -0
index 2a1434bb..4bd5650f 100644
@@ -932,6 +932,9 @@ else
 fi
 
 _canonicalize_devices
+# mkfs.xfs checks for TEST_DEV before permitting < 300M filesystems. TEST_DIR
+# and QA_CHECK_FS are also checked by mkfs.xfs, but already exported elsewhere.
+export TEST_DEV
 
 # make sure this script returns success
 /bin/true
Signature · 1 line
2.35.3
#1 lore raw

PATCH 2/2 tests: _fail on _scratch_mkfs_sized failure

If _scratch_mkfs_sized() fails, e.g. due to an FS not supporting the provided size, tests may subsequently mount and run atop a previously created (e.g. non-size-bound) filesystem.
This can lead to difficult to debug failures, or for some -ENOSPC exercising tests, near infinite runtimes. Avoid this by exiting immediately if _scratch_mkfs_sized() fails.

---
 tests/btrfs/057   | 3 ++-
 tests/btrfs/132   | 3 ++-
 tests/btrfs/170   | 2 +-
 tests/btrfs/177   | 2 +-
 tests/btrfs/204   | 2 +-
 tests/btrfs/217   | 3 ++-
 tests/btrfs/237   | 1 +
 tests/btrfs/250   | 2 +-
 tests/btrfs/253   | 3 ++-
 tests/ext4/004    | 3 ++-
 tests/ext4/036    | 2 +-
 tests/ext4/038    | 3 ++-
 tests/ext4/039    | 3 ++-
 tests/ext4/048    | 3 ++-
 tests/ext4/050    | 3 ++-
 tests/ext4/271    | 3 ++-
 tests/ext4/307    | 3 ++-
 tests/f2fs/001    | 3 ++-
 tests/generic/027 | 3 ++-
 tests/generic/081 | 3 ++-
 tests/generic/085 | 2 +-
 tests/generic/096 | 3 ++-
 tests/generic/102 | 2 +-
 tests/generic/204 | 2 +-
 tests/generic/224 | 3 ++-
 tests/generic/226 | 3 ++-
 tests/generic/250 | 2 +-
 tests/generic/252 | 2 +-
 tests/generic/256 | 3 ++-
 tests/generic/269 | 3 ++-
 tests/generic/270 | 3 ++-
 tests/generic/273 | 3 ++-
 tests/generic/274 | 3 ++-
 tests/generic/275 | 3 ++-
 tests/generic/300 | 2 +-
 tests/generic/312 | 2 +-
 tests/generic/320 | 2 +-
 tests/generic/333 | 3 ++-
 tests/generic/334 | 3 ++-
 tests/generic/361 | 3 ++-
 tests/generic/371 | 3 ++-
 tests/generic/387 | 3 ++-
 tests/generic/399 | 2 +-
 tests/generic/416 | 2 +-
 tests/generic/427 | 3 ++-
 tests/generic/449 | 3 ++-
 tests/generic/459 | 3 ++-
 tests/generic/488 | 3 ++-
 tests/generic/511 | 3 ++-
 tests/generic/515 | 3 ++-
 tests/generic/520 | 2 +-
 tests/generic/536 | 3 ++-
 tests/generic/546 | 3 ++-
 tests/generic/558 | 3 ++-
 tests/generic/559 | 2 +-
 tests/generic/562 | 3 ++-
 tests/generic/619 | 2 +-
 tests/generic/626 | 3 ++-
 tests/generic/679 | 3 ++-
 tests/xfs/075     | 2 +-
 tests/xfs/107     | 3 ++-
 tests/xfs/118     | 3 ++-
 tests/xfs/127     | 3 ++-
 tests/xfs/227     | 3 ++-
 tests/xfs/233     | 3 ++-
 tests/xfs/442     | 3 ++-
 tests/xfs/529     | 3 ++-
 tests/xfs/532     | 3 ++-
 tests/xfs/534     | 3 ++-
 tests/xfs/535     | 3 ++-
 tests/xfs/538     | 3 ++-
 71 files changed, 122 insertions(+), 70 deletions(-)
tests/btrfs/057 +2 -1
index e932a657..ff002c86 100755
@@ -17,7 +17,8 @@ _supported_fs btrfs
 _require_scratch
 _require_qgroup_rescan
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 _scratch_mount
 
tests/btrfs/132 +2 -1
index f50420f5..b10b8e2a 100755
@@ -35,7 +35,8 @@ _require_scratch
 # to further increase the possibility
 # Since the false ENOSPC happens due to incorrect metadata reservation,
 # larger nodesize and small fs will make it much easier to reproduce
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # Recommended to use MOUNT_OPTIONS="-o compress" to trigger the bug
 _scratch_mount
tests/btrfs/170 +1 -1
index ab105d36..103d097f 100755
@@ -25,7 +25,7 @@ _require_xfs_io_command "falloc" "-k"
 # later want to not have more space available for allocating data extents but
 # still have enough metadata space free for creating the snapshot.
 fs_size=$((2 * 1024 * 1024 * 1024)) # 2Gb
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 
 # Mount without space cache so that we can precisely fill all data space and
 # unallocated space later (space cache v1 uses data block groups).
tests/btrfs/177 +1 -1
index 7b004b83..4de18785 100755
@@ -47,7 +47,7 @@ _require_scratch_size $((3 * 1024 * 1024)) #kB
 
 # First, create a 1GB filesystem.
 fssize=$((1024 * 1024 * 1024))
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create a small file and run balance so we shall deal with the chunk
tests/btrfs/204 +1 -1
index ec751e42..7c036181 100755
@@ -20,7 +20,7 @@ _supported_fs btrfs
 _require_scratch
 _require_xfs_io_command "fpunch"
 
-_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full || _fail "mkfs failed"
 
 # max_inline ensures data is not inlined within metadata extents
 _scratch_mount "-o max_inline=0,nodatacow"
tests/btrfs/217 +2 -1
index 92bbba23..4be154b0 100755
@@ -23,7 +23,8 @@ _require_scratch_size $((5 * 1024 * 1024)) #kB
 _require_fstrim
 
 # Create a 5G fs
-_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Fstrim to populate the device->alloc_status CHUNK_TRIMMED bits
tests/btrfs/237 +1 -0
index 367019b6..823bf18a 100755
@@ -53,6 +53,7 @@ if [[ $devsize -gt $fssize ]]; then
 else
 	_scratch_mkfs >> $seqres.full 2>&1
 fi
+[[ $? -ne 0 ]] && _fail "mkfs failed"
 _scratch_mount -o commit=1 # 1s commit time to speed up test
 
 uuid=$($BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV |grep uuid: |\
tests/btrfs/250 +1 -1
index e7ddc2f1..ab39bfdb 100755
@@ -36,7 +36,7 @@ _require_odirect
 # space available for allocating data extents but still have enough metadata
 # space free for the file writes.
 fs_size=$((1024 * 1024 * 1024)) # 1G
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create our test file with the NOCOW attribute set.
tests/btrfs/253 +2 -1
index 5fbce070..2273e690 100755
@@ -89,7 +89,8 @@ rm -f "${seqres}.full"
 
 # Make filesystem. 10GB is needed to test different chunk sizes for
 # metadata and data and the default size for volumes > 5GB is different.
-_scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # Check if there is sufficient sysfs support.
tests/ext4/004 +2 -1
index 0c2ad897..d23cc547 100755
@@ -54,7 +54,8 @@ _require_command "$RESTORE_PROG" restore
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 rm -rf $restore_dir $TEST_DIR/restoresymtable
 
tests/ext4/036 +1 -1
index 60ab0b90..a4bbe528 100755
@@ -21,7 +21,7 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # create a file and get its inode number, usually it's 12, but to be accurate
tests/ext4/038 +2 -1
index 596de65b..a84d070b 100755
@@ -23,7 +23,8 @@ echo "Silence is golden"
 # it is better to test all reserved inode numbers 1-10 here
 for i in {1..10}; do
 	# create smaller filesystems to save test time
-	_scratch_mkfs_sized $((16 * 1024 * 1024)) >>$seqres.full 2>&1
+	_scratch_mkfs_sized $((16 * 1024 * 1024)) >>$seqres.full 2>&1 \
+		|| _fail "mkfs failed"
 	$DEBUGFS_PROG -w -R "ssv last_orphan $i" $SCRATCH_DEV >>$seqres.full 2>&1
 	_scratch_mount
 	_scratch_unmount
tests/ext4/039 +2 -1
index 4ca4058a..4945bab2 100755
@@ -61,7 +61,8 @@ _supported_fs ext3 ext4
 _require_scratch
 _exclude_scratch_mount_option dax
 
-_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 if ! _workout; then
tests/ext4/048 +2 -1
index c23c0ea3..a499038e 100755
@@ -81,7 +81,8 @@ test_file1="test0001"
 test_file2="test0002"
 test_file3="test0003"
 
-_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # create scratch dir for testing
 # create some files with no name a substr of another name so we can grep later
tests/ext4/050 +2 -1
index 6f93b86d..95326771 100755
@@ -24,7 +24,8 @@ _require_test_program "checkpoint_journal"
 
 testdir="${SCRATCH_MNT}/testdir"
 
-_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _scratch_mount >> $seqres.full 2>&1
 blocksize=$(_get_block_size $SCRATCH_MNT)
tests/ext4/271 +2 -1
index 8d9bd7dc..feceb7f3 100755
@@ -20,7 +20,8 @@ _require_scratch
 _exclude_scratch_mount_option "data" "commit" "journal_checksum" \
 			      "journal_async_commit"
 
-_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # -onoload and EXT4_SYNC_FL on file is important becase result in
 # metadata sync writes inside ext4_handle_dirty_metadata()
tests/ext4/307 +2 -1
index 8b1cfc9e..b63e1e91 100755
@@ -41,7 +41,8 @@ _require_scratch
 _require_defrag
 _require_xfs_io_command "falloc"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 _workout
tests/f2fs/001 +2 -1
index 2bf39d8c..4c7d7c7a 100755
@@ -29,7 +29,8 @@ testfile=$SCRATCH_MNT/testfile
 dummyfile=$SCRATCH_MNT/dummyfile
 
 # build 4GB filesystem
-_scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1
+_scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "==== create small file ===="
tests/generic/027 +2 -1
index 47f1981d..a8689a15 100755
@@ -35,7 +35,8 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "Reserve 2M space" >>$seqres.full
tests/generic/081 +2 -1
index 0996f221..71ef19e0 100755
@@ -67,7 +67,8 @@ lvsize=$((size * 85 / 100))	 # ~256M
 
 # make sure there's enough disk space for 256M lv, test for 300M here in case
 # lvm uses some space for metadata
-_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
 # (like 2.02.95 in RHEL6) don't support --yes option
tests/generic/085 +1 -1
index 786d8e6f..7e501cf8 100755
@@ -52,7 +52,7 @@ echo "Silence is golden"
 
 size=$((256 * 1024 * 1024))
 size_in_sector=$((size / 512))
-_scratch_mkfs_sized $size >>$seqres.full 2>&1
+_scratch_mkfs_sized $size >>$seqres.full 2>&1 || _fail "mkfs failed"
 
 node=$seq-test
 lvdev=/dev/mapper/$node
tests/generic/096 +2 -1
index 41b646c0..d76b2f53 100755
@@ -23,7 +23,8 @@ _require_xfs_io_command "fzero"
 echo "Silence is golden"
 
 # Use smaller scratch fs to shorten the test time
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 testfile=$SCRATCH_MNT/$seq.$$
tests/generic/102 +1 -1
index 3536ebf7..396cb80c 100755
@@ -23,7 +23,7 @@ _supported_fs generic
 _require_scratch
 
 dev_size=$((1024 * 1024 * 1024))     # 1GB filesystem
-_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 for ((i = 0; i < 10; i++)); do
tests/generic/204 +1 -1
index a33a090f..31b920f2 100755
@@ -31,7 +31,7 @@ _require_scratch
 [ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=16m -i maxpct=50"
 
 SIZE=`expr 115 \* 1024 \* 1024`
-_scratch_mkfs_sized $SIZE 2> /dev/null > $tmp.mkfs.raw
+_scratch_mkfs_sized $SIZE 2> /dev/null > $tmp.mkfs.raw || _fail "mkfs failed"
 cat $tmp.mkfs.raw | _filter_mkfs 2> $tmp.mkfs > /dev/null
 _scratch_mount
 
tests/generic/224 +2 -1
index 26055ea2..6407aed0 100755
@@ -30,7 +30,8 @@ _supported_fs generic
 _require_scratch
 
 # make a 1GB filesystem
-_scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1
+_scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # set the reserved block pool to almost empty for XFS
tests/generic/226 +2 -1
index 34434730..5b0d5088 100755
@@ -19,7 +19,8 @@ _require_odirect
 
 _scratch_unmount 2>/dev/null
 echo "--> mkfs 256m filesystem"
-_scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1
+_scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 loops=16
tests/generic/250 +1 -1
index 97e9522f..b4b98ad2 100755
@@ -35,7 +35,7 @@ unset SCRATCH_RTDEV
 fssize=$((196 * 1048576))
 echo "Format and mount"
 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 _dmerror_unmount
tests/generic/252 +1 -1
index 8c5adb53..6108183b 100755
@@ -36,7 +36,7 @@ unset SCRATCH_RTDEV
 fssize=$((196 * 1048576))
 echo "Format and mount"
 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 _dmerror_unmount
tests/generic/256 +2 -1
index ea6cc293..aa72a2a4 100755
@@ -89,7 +89,8 @@ _test_full_fs_punch()
 
 # Make a small file system to fill
 _scratch_unmount &> /dev/null
-_scratch_mkfs_sized $(( 1536 * 1024 * 1024 )) &> /dev/null
+_scratch_mkfs_sized $(( 1536 * 1024 * 1024 )) &> /dev/null \
+	|| _fail "mkfs failed"
 _scratch_mount
 # Test must be able to write files with non-root permissions
 chmod 777 $SCRATCH_MNT
tests/generic/269 +2 -1
index b7cdecd9..c10bc908 100755
@@ -42,7 +42,8 @@ _workout()
 _supported_fs generic
 _require_scratch
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 if ! _workout; then
tests/generic/270 +2 -1
index e7329c2f..3c495a5d 100755
@@ -61,7 +61,8 @@ _require_command "$KILLALL_PROG" killall
 _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount "-o usrquota,grpquota"
 chmod 777 $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
tests/generic/273 +2 -1
index 54c19996..53e18be7 100755
@@ -125,7 +125,8 @@ echo "start the workload"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 _do_workload
tests/generic/274 +2 -1
index 8c0e420e..ee1f71ea 100755
@@ -39,7 +39,8 @@ echo "preallocation test"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create a 4k file and Allocate 4M past EOF on that file
tests/generic/275 +2 -1
index f3b05409..effaee63 100755
@@ -34,7 +34,8 @@ echo "write until ENOSPC test"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Certain filesystems such as XFS require sufficient free blocks to handle the
tests/generic/300 +1 -1
index 5ff141d3..fea951c3 100755
@@ -110,7 +110,7 @@ EOF
 
 _require_fio $fio_config
 
-_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
+_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 echo ""
tests/generic/312 +1 -1
index 1926deb8..03ddd7c5 100755
@@ -23,7 +23,7 @@ _require_scratch
 # 5G in byte
 fssize=$((2**30 * 5))
 
-_scratch_mkfs_sized $fssize >>$seqres.full 2>&1
+_scratch_mkfs_sized $fssize >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >>$seqres.full 2>&1
 
 echo "Silence is golden"
tests/generic/320 +1 -1
index ea65537f..15178435 100755
@@ -79,7 +79,7 @@ do_workload()
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >>$seqres.full 2>&1
 
 do_workload
tests/generic/333 +2 -1
index bf1967ce..fad4e357 100755
@@ -30,7 +30,8 @@ _require_cp_reflink
 _require_odirect
 
 echo "Format and mount"
-_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/generic/334 +2 -1
index b9c14b87..f78641d6 100755
@@ -29,7 +29,8 @@ _require_scratch_reflink
 _require_cp_reflink
 
 echo "Format and mount"
-_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/generic/361 +2 -1
index d76d2635..2ba49e9c 100755
@@ -33,7 +33,8 @@ _require_loop
 _require_sparse_files
 
 # create a small filesystem to hold another filesystem image
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # create the sparse fs image and mount point
tests/generic/371 +2 -1
index a2fdaf7b..8861dc40 100755
@@ -20,7 +20,8 @@ _require_scratch
 _require_xfs_io_command "falloc"
 test "$FSTYP" = "xfs" && _require_xfs_io_command "extsize"
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Disable speculative post-EOF preallocation on XFS, which can grow fast enough
tests/generic/387 +2 -1
index 25ca86bb..0ee01594 100755
@@ -19,7 +19,8 @@ _supported_fs generic
 _require_scratch_reflink
 
 #btrfs needs 256mb to create default blockgroup fs
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 testfile=$SCRATCH_MNT/testfile
tests/generic/399 +1 -1
index a5aa7107..dc42d5c8 100755
@@ -42,7 +42,7 @@ fs_size_in_mb=64
 fs_size=$((fs_size_in_mb * 1024 * 1024))
 dd if=/dev/zero of=$SCRATCH_DEV bs=$((1024 * 1024)) \
 	count=$fs_size_in_mb &>> $seqres.full
-_scratch_mkfs_sized_encrypted $fs_size &>> $seqres.full
+_scratch_mkfs_sized_encrypted $fs_size &>> $seqres.full || _fail "mkfs failed"
 _scratch_mount
 
 keydesc=$(_generate_session_encryption_key)
tests/generic/416 +1 -1
index 0f6e3bc9..b0ce71c9 100755
@@ -28,7 +28,7 @@ page_size=$(_get_page_size)
 nr_files=$(($fs_size / $page_size))
 
 # Use small fs to make the fill more faster
-_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
 
 _scratch_mount
 
tests/generic/427 +2 -1
index 26385d36..01df59b1 100755
@@ -27,7 +27,8 @@ _require_aiodio aio-dio-eof-race
 _require_no_compress
 
 # limit the filesystem size, to save the time of filling filesystem
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # try to write more bytes than filesystem size to fill the filesystem,
tests/generic/449 +2 -1
index 2b77a6a4..916d1985 100755
@@ -24,7 +24,8 @@ _require_test
 _require_acls
 _require_attrs trusted
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount || _fail "mount failed"
 
 # This is a test of xattr behavior when we run out of disk space for xattrs,
tests/generic/459 +2 -1
index c3f0b2b0..57cd0c52 100755
@@ -76,7 +76,8 @@ is_shutdown_or_ro()
 }
 
 # Ensure we have enough disk space
-_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # Create a 200MB dm-thin POOL
 $LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
tests/generic/488 +2 -1
index 7b9dcc18..26f08040 100755
@@ -16,7 +16,8 @@ _supported_fs generic
 _require_scratch
 _require_test_program "multi_open_unlink"
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 test_file="$SCRATCH_MNT/$seq"
tests/generic/511 +2 -1
index 61c21e42..d96d46df 100755
@@ -19,7 +19,8 @@ _require_scratch
 _require_xfs_io_command "falloc" "-k"
 _require_xfs_io_command "fzero"
 
-_scratch_mkfs_sized $((1024 * 1024 * 256)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 256)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 $XFS_IO_PROG -fc "pwrite 0 256m" -c fsync $SCRATCH_MNT/file >>$seqres.full 2>&1
tests/generic/515 +2 -1
index 1d537dec..0b14f9e3 100755
@@ -24,7 +24,8 @@ _require_xfs_io_command "falloc"
 # Fill disk with a well known pattern so that stale data exposure becomes much
 # more obvious.
 $XFS_IO_PROG -c "pwrite -S 0x58 -b 1m 0 300m" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 DONOR1=$SCRATCH_MNT/a
tests/generic/520 +1 -1
index ad6764c7..9bf2a6eb 100755
@@ -33,7 +33,7 @@ _require_scratch_nocheck
 _require_dm_target flakey
 
 # initialize scratch device
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 
tests/generic/536 +2 -1
index 986ea1ee..3ff56914 100755
@@ -21,7 +21,8 @@ _require_scratch
 _require_scratch_shutdown
 
 # create a small fs and initialize free blocks with a unique pattern
-_scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 100m" -c fsync $SCRATCH_MNT/spc \
 	>> $seqres.full 2>&1
tests/generic/546 +2 -1
index 2eb99543..75de5478 100755
@@ -35,7 +35,8 @@ _require_xfs_io_command "falloc"
 _require_scratch_reflink
 _require_dm_target flakey
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 _mount_flakey
tests/generic/558 +2 -1
index 510b06f2..c6b9e2e0 100755
@@ -34,7 +34,8 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 i=0
tests/generic/559 +1 -1
index 98ab4474..26f07443 100755
@@ -18,7 +18,7 @@ _supported_fs generic
 _require_scratch_duperemove
 
 fssize=$((2 * 1024 * 1024 * 1024))
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # fill the fs with a big file has same contents
tests/generic/562 +2 -1
index 7d98e569..d5a5993b 100755
@@ -21,7 +21,8 @@ _require_scratch_reflink
 _require_test_program "punch-alternating"
 _require_xfs_io_command "fpunch"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 file_size=$(( 200 * 1024 * 1024 )) # 200Mb
tests/generic/619 +1 -1
index c4bdfbce..b844d2f8 100755
@@ -132,7 +132,7 @@ run_testcase()
 
 	for i in $(eval echo "{1..$test_iteration_cnt}"); do
 		# Setup the device
-		_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
+		_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1 || _fail "mkfs failed"
 		_scratch_mount
 
 		debug "===== Test: $test_name iteration: $i starts ====="
tests/generic/626 +2 -1
index 7e577798..afb9322a 100755
@@ -22,7 +22,8 @@ _supported_fs generic
 _require_scratch
 _require_renameat2 whiteout
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create lots of files, to help to trigger the bug easily
tests/generic/679 +2 -1
index ddf975a2..f6e95117 100755
@@ -29,7 +29,8 @@ _supported_fs ^xfs
 rm -f $seqres.full
 
 # Create a 1G filesystem.
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create a file with a size of 600M and two holes, each with a size of 1M and
tests/xfs/075 +1 -1
index ec056fb3..82307e68 100755
@@ -22,7 +22,7 @@ _require_scratch
 _qmount_option "defaults"
 
 echo "Silence is golden"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >$seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >$seqres.full || _fail "mkfs failed"
 
 # first ro mount with norecovery
 _try_scratch_mount "-o ro,norecovery" >>$seqres.full 2>&1 \
tests/xfs/107 +2 -1
index 1ea9c492..c374d15d 100755
@@ -32,7 +32,8 @@ size_mb=256
 # reproduce within the first 500KB's worth of ALLOCSP calls, so running up
 # to 16MB should suffice.
 $XFS_IO_PROG -d -c "pwrite -S 0x58 -b 8m 0 ${size_mb}m" $SCRATCH_DEV > $seqres.full
-MKFS_OPTIONS="-K $MKFS_OPTIONS" _scratch_mkfs_sized $((size_mb * 1048576)) >> $seqres.full
+MKFS_OPTIONS="-K $MKFS_OPTIONS" _scratch_mkfs_sized $((size_mb * 1048576)) \
+	>> $seqres.full || _fail "mkfs failed"
 
 _scratch_mount
 
tests/xfs/118 +2 -1
index 6bb81a3a..f6d17706 100755
@@ -28,7 +28,8 @@ _require_command "$XFS_FSR_PROG" "xfs_fsr"
 _require_xfs_io_command "falloc"
 
 # 50M
-_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "Silence is golden"
tests/xfs/127 +2 -1
index f39b0582..c4237860 100755
@@ -20,7 +20,8 @@ _require_no_large_scratch_dev
 _require_cp_reflink
 
 echo "Format and mount"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/xfs/227 +2 -1
index cd927dc4..0556412c 100755
@@ -122,7 +122,8 @@ create_target_attr_last()
 }
 
 # use a small filesystem so we can control freespace easily
-_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 fragment_freespace
 
tests/xfs/233 +2 -1
index 2b2b8666..dedd1ef8 100755
@@ -18,7 +18,8 @@ _require_xfs_scratch_rmapbt
 _require_no_large_scratch_dev
 
 echo "Format and mount"
-_scratch_mkfs_sized $((2 * 4096 * 4096)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 4096 * 4096)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/xfs/442 +2 -1
index b04b1c83..d55ccc17 100755
@@ -68,7 +68,8 @@ _qmount_option "usrquota,grpquota,prjquota"
 # operations as delalloc for quota accounting") and ("xfs: call
 # xfs_qm_dqattach before performing reflink operations") though each of those
 # tests now have separate faster-running regression tests.
-_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 nr_cpus=$((LOAD_FACTOR * 4))
tests/xfs/529 +2 -1
index cd176877..da4490b7 100755
@@ -29,7 +29,8 @@ _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount -o uquota >> $seqres.full
 
 # bmap_alloc_minlen_extent only applies to the datadev space allocator, so
tests/xfs/532 +2 -1
index 74a7ac30..06e41367 100755
@@ -26,7 +26,8 @@ _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
tests/xfs/534 +2 -1
index f17c45b8..bb940e4a 100755
@@ -22,7 +22,8 @@ _require_xfs_io_command "falloc"
 _require_xfs_io_error_injection "reduce_max_iextents"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 bsize=$(_get_file_block_size $SCRATCH_MNT)
tests/xfs/535 +2 -1
index f76c1725..1c72e3a2 100755
@@ -25,7 +25,8 @@ _require_xfs_io_command "funshare"
 _require_xfs_io_error_injection "reduce_max_iextents"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 bsize=$(_get_block_size $SCRATCH_MNT)
tests/xfs/538 +2 -1
index 0b5772a1..e8ac3918 100755
@@ -23,7 +23,8 @@ _require_test_program "punch-alternating"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
Signature · 1 line
2.35.3
#2 lore raw

Re: [PATCH 2/2] tests: _fail on _scratch_mkfs_sized failure

Quoted 6 lines · David Disseldorp

If _scratch_mkfs_sized() fails, e.g. due to an FS not supporting the provided size, tests may subsequently mount and run atop a previously created (e.g. non-size-bound) filesystem.
This can lead to difficult to debug failures, or for some -ENOSPC exercising tests, near infinite runtimes. Avoid this by exiting immediately if _scratch_mkfs_sized() fails.

I wonder, how many tests should keep going if _scratch_mkfs_sized isn't successful? Would it be simpler to make a _try_scratch_mkfs_sized for those callers, and make the main _scratch_mkfs_sized simply do

_scratch_mkfs_sized()

{
	_try_scratch_mkfs_sized $* || _fail "_scratch_mkfs_sized failed"
}

?

--D

Quoted 1,052 lines
---
 tests/btrfs/057   | 3 ++-
 tests/btrfs/132   | 3 ++-
 tests/btrfs/170   | 2 +-
 tests/btrfs/177   | 2 +-
 tests/btrfs/204   | 2 +-
 tests/btrfs/217   | 3 ++-
 tests/btrfs/237   | 1 +
 tests/btrfs/250   | 2 +-
 tests/btrfs/253   | 3 ++-
 tests/ext4/004    | 3 ++-
 tests/ext4/036    | 2 +-
 tests/ext4/038    | 3 ++-
 tests/ext4/039    | 3 ++-
 tests/ext4/048    | 3 ++-
 tests/ext4/050    | 3 ++-
 tests/ext4/271    | 3 ++-
 tests/ext4/307    | 3 ++-
 tests/f2fs/001    | 3 ++-
 tests/generic/027 | 3 ++-
 tests/generic/081 | 3 ++-
 tests/generic/085 | 2 +-
 tests/generic/096 | 3 ++-
 tests/generic/102 | 2 +-
 tests/generic/204 | 2 +-
 tests/generic/224 | 3 ++-
 tests/generic/226 | 3 ++-
 tests/generic/250 | 2 +-
 tests/generic/252 | 2 +-
 tests/generic/256 | 3 ++-
 tests/generic/269 | 3 ++-
 tests/generic/270 | 3 ++-
 tests/generic/273 | 3 ++-
 tests/generic/274 | 3 ++-
 tests/generic/275 | 3 ++-
 tests/generic/300 | 2 +-
 tests/generic/312 | 2 +-
 tests/generic/320 | 2 +-
 tests/generic/333 | 3 ++-
 tests/generic/334 | 3 ++-
 tests/generic/361 | 3 ++-
 tests/generic/371 | 3 ++-
 tests/generic/387 | 3 ++-
 tests/generic/399 | 2 +-
 tests/generic/416 | 2 +-
 tests/generic/427 | 3 ++-
 tests/generic/449 | 3 ++-
 tests/generic/459 | 3 ++-
 tests/generic/488 | 3 ++-
 tests/generic/511 | 3 ++-
 tests/generic/515 | 3 ++-
 tests/generic/520 | 2 +-
 tests/generic/536 | 3 ++-
 tests/generic/546 | 3 ++-
 tests/generic/558 | 3 ++-
 tests/generic/559 | 2 +-
 tests/generic/562 | 3 ++-
 tests/generic/619 | 2 +-
 tests/generic/626 | 3 ++-
 tests/generic/679 | 3 ++-
 tests/xfs/075     | 2 +-
 tests/xfs/107     | 3 ++-
 tests/xfs/118     | 3 ++-
 tests/xfs/127     | 3 ++-
 tests/xfs/227     | 3 ++-
 tests/xfs/233     | 3 ++-
 tests/xfs/442     | 3 ++-
 tests/xfs/529     | 3 ++-
 tests/xfs/532     | 3 ++-
 tests/xfs/534     | 3 ++-
 tests/xfs/535     | 3 ++-
 tests/xfs/538     | 3 ++-
 71 files changed, 122 insertions(+), 70 deletions(-)
tests/btrfs/057 +2 -1
index e932a657..ff002c86 100755
@@ -17,7 +17,8 @@ _supported_fs btrfs
 _require_scratch
 _require_qgroup_rescan
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 _scratch_mount
 
tests/btrfs/132 +2 -1
index f50420f5..b10b8e2a 100755
@@ -35,7 +35,8 @@ _require_scratch
 # to further increase the possibility
 # Since the false ENOSPC happens due to incorrect metadata reservation,
 # larger nodesize and small fs will make it much easier to reproduce
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # Recommended to use MOUNT_OPTIONS="-o compress" to trigger the bug
 _scratch_mount
tests/btrfs/170 +1 -1
index ab105d36..103d097f 100755
@@ -25,7 +25,7 @@ _require_xfs_io_command "falloc" "-k"
 # later want to not have more space available for allocating data extents but
 # still have enough metadata space free for creating the snapshot.
 fs_size=$((2 * 1024 * 1024 * 1024)) # 2Gb
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 
 # Mount without space cache so that we can precisely fill all data space and
 # unallocated space later (space cache v1 uses data block groups).
tests/btrfs/177 +1 -1
index 7b004b83..4de18785 100755
@@ -47,7 +47,7 @@ _require_scratch_size $((3 * 1024 * 1024)) #kB
 
 # First, create a 1GB filesystem.
 fssize=$((1024 * 1024 * 1024))
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create a small file and run balance so we shall deal with the chunk
tests/btrfs/204 +1 -1
index ec751e42..7c036181 100755
@@ -20,7 +20,7 @@ _supported_fs btrfs
 _require_scratch
 _require_xfs_io_command "fpunch"
 
-_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full || _fail "mkfs failed"
 
 # max_inline ensures data is not inlined within metadata extents
 _scratch_mount "-o max_inline=0,nodatacow"
tests/btrfs/217 +2 -1
index 92bbba23..4be154b0 100755
@@ -23,7 +23,8 @@ _require_scratch_size $((5 * 1024 * 1024)) #kB
 _require_fstrim
 
 # Create a 5G fs
-_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Fstrim to populate the device->alloc_status CHUNK_TRIMMED bits
tests/btrfs/237 +1 -0
index 367019b6..823bf18a 100755
@@ -53,6 +53,7 @@ if [[ $devsize -gt $fssize ]]; then
 else
 	_scratch_mkfs >> $seqres.full 2>&1
 fi
+[[ $? -ne 0 ]] && _fail "mkfs failed"
 _scratch_mount -o commit=1 # 1s commit time to speed up test
 
 uuid=$($BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV |grep uuid: |\
tests/btrfs/250 +1 -1
index e7ddc2f1..ab39bfdb 100755
@@ -36,7 +36,7 @@ _require_odirect
 # space available for allocating data extents but still have enough metadata
 # space free for the file writes.
 fs_size=$((1024 * 1024 * 1024)) # 1G
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create our test file with the NOCOW attribute set.
tests/btrfs/253 +2 -1
index 5fbce070..2273e690 100755
@@ -89,7 +89,8 @@ rm -f "${seqres}.full"
 
 # Make filesystem. 10GB is needed to test different chunk sizes for
 # metadata and data and the default size for volumes > 5GB is different.
-_scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # Check if there is sufficient sysfs support.
tests/ext4/004 +2 -1
index 0c2ad897..d23cc547 100755
@@ -54,7 +54,8 @@ _require_command "$RESTORE_PROG" restore
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 rm -rf $restore_dir $TEST_DIR/restoresymtable
 
tests/ext4/036 +1 -1
index 60ab0b90..a4bbe528 100755
@@ -21,7 +21,7 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # create a file and get its inode number, usually it's 12, but to be accurate
tests/ext4/038 +2 -1
index 596de65b..a84d070b 100755
@@ -23,7 +23,8 @@ echo "Silence is golden"
 # it is better to test all reserved inode numbers 1-10 here
 for i in {1..10}; do
 	# create smaller filesystems to save test time
-	_scratch_mkfs_sized $((16 * 1024 * 1024)) >>$seqres.full 2>&1
+	_scratch_mkfs_sized $((16 * 1024 * 1024)) >>$seqres.full 2>&1 \
+		|| _fail "mkfs failed"
 	$DEBUGFS_PROG -w -R "ssv last_orphan $i" $SCRATCH_DEV >>$seqres.full 2>&1
 	_scratch_mount
 	_scratch_unmount
tests/ext4/039 +2 -1
index 4ca4058a..4945bab2 100755
@@ -61,7 +61,8 @@ _supported_fs ext3 ext4
 _require_scratch
 _exclude_scratch_mount_option dax
 
-_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 if ! _workout; then
tests/ext4/048 +2 -1
index c23c0ea3..a499038e 100755
@@ -81,7 +81,8 @@ test_file1="test0001"
 test_file2="test0002"
 test_file3="test0003"
 
-_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # create scratch dir for testing
 # create some files with no name a substr of another name so we can grep later
tests/ext4/050 +2 -1
index 6f93b86d..95326771 100755
@@ -24,7 +24,8 @@ _require_test_program "checkpoint_journal"
 
 testdir="${SCRATCH_MNT}/testdir"
 
-_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _scratch_mount >> $seqres.full 2>&1
 blocksize=$(_get_block_size $SCRATCH_MNT)
tests/ext4/271 +2 -1
index 8d9bd7dc..feceb7f3 100755
@@ -20,7 +20,8 @@ _require_scratch
 _exclude_scratch_mount_option "data" "commit" "journal_checksum" \
 			      "journal_async_commit"
 
-_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # -onoload and EXT4_SYNC_FL on file is important becase result in
 # metadata sync writes inside ext4_handle_dirty_metadata()
tests/ext4/307 +2 -1
index 8b1cfc9e..b63e1e91 100755
@@ -41,7 +41,8 @@ _require_scratch
 _require_defrag
 _require_xfs_io_command "falloc"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 _workout
tests/f2fs/001 +2 -1
index 2bf39d8c..4c7d7c7a 100755
@@ -29,7 +29,8 @@ testfile=$SCRATCH_MNT/testfile
 dummyfile=$SCRATCH_MNT/dummyfile
 
 # build 4GB filesystem
-_scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1
+_scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "==== create small file ===="
tests/generic/027 +2 -1
index 47f1981d..a8689a15 100755
@@ -35,7 +35,8 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "Reserve 2M space" >>$seqres.full
tests/generic/081 +2 -1
index 0996f221..71ef19e0 100755
@@ -67,7 +67,8 @@ lvsize=$((size * 85 / 100))	 # ~256M
 
 # make sure there's enough disk space for 256M lv, test for 300M here in case
 # lvm uses some space for metadata
-_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
 # (like 2.02.95 in RHEL6) don't support --yes option
tests/generic/085 +1 -1
index 786d8e6f..7e501cf8 100755
@@ -52,7 +52,7 @@ echo "Silence is golden"
 
 size=$((256 * 1024 * 1024))
 size_in_sector=$((size / 512))
-_scratch_mkfs_sized $size >>$seqres.full 2>&1
+_scratch_mkfs_sized $size >>$seqres.full 2>&1 || _fail "mkfs failed"
 
 node=$seq-test
 lvdev=/dev/mapper/$node
tests/generic/096 +2 -1
index 41b646c0..d76b2f53 100755
@@ -23,7 +23,8 @@ _require_xfs_io_command "fzero"
 echo "Silence is golden"
 
 # Use smaller scratch fs to shorten the test time
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 testfile=$SCRATCH_MNT/$seq.$$
tests/generic/102 +1 -1
index 3536ebf7..396cb80c 100755
@@ -23,7 +23,7 @@ _supported_fs generic
 _require_scratch
 
 dev_size=$((1024 * 1024 * 1024))     # 1GB filesystem
-_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 for ((i = 0; i < 10; i++)); do
tests/generic/204 +1 -1
index a33a090f..31b920f2 100755
@@ -31,7 +31,7 @@ _require_scratch
 [ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=16m -i maxpct=50"
 
 SIZE=`expr 115 \* 1024 \* 1024`
-_scratch_mkfs_sized $SIZE 2> /dev/null > $tmp.mkfs.raw
+_scratch_mkfs_sized $SIZE 2> /dev/null > $tmp.mkfs.raw || _fail "mkfs failed"
 cat $tmp.mkfs.raw | _filter_mkfs 2> $tmp.mkfs > /dev/null
 _scratch_mount
 
tests/generic/224 +2 -1
index 26055ea2..6407aed0 100755
@@ -30,7 +30,8 @@ _supported_fs generic
 _require_scratch
 
 # make a 1GB filesystem
-_scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1
+_scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # set the reserved block pool to almost empty for XFS
tests/generic/226 +2 -1
index 34434730..5b0d5088 100755
@@ -19,7 +19,8 @@ _require_odirect
 
 _scratch_unmount 2>/dev/null
 echo "--> mkfs 256m filesystem"
-_scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1
+_scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 loops=16
tests/generic/250 +1 -1
index 97e9522f..b4b98ad2 100755
@@ -35,7 +35,7 @@ unset SCRATCH_RTDEV
 fssize=$((196 * 1048576))
 echo "Format and mount"
 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 _dmerror_unmount
tests/generic/252 +1 -1
index 8c5adb53..6108183b 100755
@@ -36,7 +36,7 @@ unset SCRATCH_RTDEV
 fssize=$((196 * 1048576))
 echo "Format and mount"
 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 _dmerror_unmount
tests/generic/256 +2 -1
index ea6cc293..aa72a2a4 100755
@@ -89,7 +89,8 @@ _test_full_fs_punch()
 
 # Make a small file system to fill
 _scratch_unmount &> /dev/null
-_scratch_mkfs_sized $(( 1536 * 1024 * 1024 )) &> /dev/null
+_scratch_mkfs_sized $(( 1536 * 1024 * 1024 )) &> /dev/null \
+	|| _fail "mkfs failed"
 _scratch_mount
 # Test must be able to write files with non-root permissions
 chmod 777 $SCRATCH_MNT
tests/generic/269 +2 -1
index b7cdecd9..c10bc908 100755
@@ -42,7 +42,8 @@ _workout()
 _supported_fs generic
 _require_scratch
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 if ! _workout; then
tests/generic/270 +2 -1
index e7329c2f..3c495a5d 100755
@@ -61,7 +61,8 @@ _require_command "$KILLALL_PROG" killall
 _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount "-o usrquota,grpquota"
 chmod 777 $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
tests/generic/273 +2 -1
index 54c19996..53e18be7 100755
@@ -125,7 +125,8 @@ echo "start the workload"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 _do_workload
tests/generic/274 +2 -1
index 8c0e420e..ee1f71ea 100755
@@ -39,7 +39,8 @@ echo "preallocation test"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create a 4k file and Allocate 4M past EOF on that file
tests/generic/275 +2 -1
index f3b05409..effaee63 100755
@@ -34,7 +34,8 @@ echo "write until ENOSPC test"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Certain filesystems such as XFS require sufficient free blocks to handle the
tests/generic/300 +1 -1
index 5ff141d3..fea951c3 100755
@@ -110,7 +110,7 @@ EOF
 
 _require_fio $fio_config
 
-_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
+_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 echo ""
tests/generic/312 +1 -1
index 1926deb8..03ddd7c5 100755
@@ -23,7 +23,7 @@ _require_scratch
 # 5G in byte
 fssize=$((2**30 * 5))
 
-_scratch_mkfs_sized $fssize >>$seqres.full 2>&1
+_scratch_mkfs_sized $fssize >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >>$seqres.full 2>&1
 
 echo "Silence is golden"
tests/generic/320 +1 -1
index ea65537f..15178435 100755
@@ -79,7 +79,7 @@ do_workload()
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >>$seqres.full 2>&1
 
 do_workload
tests/generic/333 +2 -1
index bf1967ce..fad4e357 100755
@@ -30,7 +30,8 @@ _require_cp_reflink
 _require_odirect
 
 echo "Format and mount"
-_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/generic/334 +2 -1
index b9c14b87..f78641d6 100755
@@ -29,7 +29,8 @@ _require_scratch_reflink
 _require_cp_reflink
 
 echo "Format and mount"
-_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/generic/361 +2 -1
index d76d2635..2ba49e9c 100755
@@ -33,7 +33,8 @@ _require_loop
 _require_sparse_files
 
 # create a small filesystem to hold another filesystem image
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # create the sparse fs image and mount point
tests/generic/371 +2 -1
index a2fdaf7b..8861dc40 100755
@@ -20,7 +20,8 @@ _require_scratch
 _require_xfs_io_command "falloc"
 test "$FSTYP" = "xfs" && _require_xfs_io_command "extsize"
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Disable speculative post-EOF preallocation on XFS, which can grow fast enough
tests/generic/387 +2 -1
index 25ca86bb..0ee01594 100755
@@ -19,7 +19,8 @@ _supported_fs generic
 _require_scratch_reflink
 
 #btrfs needs 256mb to create default blockgroup fs
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 testfile=$SCRATCH_MNT/testfile
tests/generic/399 +1 -1
index a5aa7107..dc42d5c8 100755
@@ -42,7 +42,7 @@ fs_size_in_mb=64
 fs_size=$((fs_size_in_mb * 1024 * 1024))
 dd if=/dev/zero of=$SCRATCH_DEV bs=$((1024 * 1024)) \
 	count=$fs_size_in_mb &>> $seqres.full
-_scratch_mkfs_sized_encrypted $fs_size &>> $seqres.full
+_scratch_mkfs_sized_encrypted $fs_size &>> $seqres.full || _fail "mkfs failed"
 _scratch_mount
 
 keydesc=$(_generate_session_encryption_key)
tests/generic/416 +1 -1
index 0f6e3bc9..b0ce71c9 100755
@@ -28,7 +28,7 @@ page_size=$(_get_page_size)
 nr_files=$(($fs_size / $page_size))
 
 # Use small fs to make the fill more faster
-_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
 
 _scratch_mount
 
tests/generic/427 +2 -1
index 26385d36..01df59b1 100755
@@ -27,7 +27,8 @@ _require_aiodio aio-dio-eof-race
 _require_no_compress
 
 # limit the filesystem size, to save the time of filling filesystem
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # try to write more bytes than filesystem size to fill the filesystem,
tests/generic/449 +2 -1
index 2b77a6a4..916d1985 100755
@@ -24,7 +24,8 @@ _require_test
 _require_acls
 _require_attrs trusted
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount || _fail "mount failed"
 
 # This is a test of xattr behavior when we run out of disk space for xattrs,
tests/generic/459 +2 -1
index c3f0b2b0..57cd0c52 100755
@@ -76,7 +76,8 @@ is_shutdown_or_ro()
 }
 
 # Ensure we have enough disk space
-_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # Create a 200MB dm-thin POOL
 $LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
tests/generic/488 +2 -1
index 7b9dcc18..26f08040 100755
@@ -16,7 +16,8 @@ _supported_fs generic
 _require_scratch
 _require_test_program "multi_open_unlink"
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 test_file="$SCRATCH_MNT/$seq"
tests/generic/511 +2 -1
index 61c21e42..d96d46df 100755
@@ -19,7 +19,8 @@ _require_scratch
 _require_xfs_io_command "falloc" "-k"
 _require_xfs_io_command "fzero"
 
-_scratch_mkfs_sized $((1024 * 1024 * 256)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 256)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 $XFS_IO_PROG -fc "pwrite 0 256m" -c fsync $SCRATCH_MNT/file >>$seqres.full 2>&1
tests/generic/515 +2 -1
index 1d537dec..0b14f9e3 100755
@@ -24,7 +24,8 @@ _require_xfs_io_command "falloc"
 # Fill disk with a well known pattern so that stale data exposure becomes much
 # more obvious.
 $XFS_IO_PROG -c "pwrite -S 0x58 -b 1m 0 300m" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 DONOR1=$SCRATCH_MNT/a
tests/generic/520 +1 -1
index ad6764c7..9bf2a6eb 100755
@@ -33,7 +33,7 @@ _require_scratch_nocheck
 _require_dm_target flakey
 
 # initialize scratch device
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 
tests/generic/536 +2 -1
index 986ea1ee..3ff56914 100755
@@ -21,7 +21,8 @@ _require_scratch
 _require_scratch_shutdown
 
 # create a small fs and initialize free blocks with a unique pattern
-_scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 100m" -c fsync $SCRATCH_MNT/spc \
 	>> $seqres.full 2>&1
tests/generic/546 +2 -1
index 2eb99543..75de5478 100755
@@ -35,7 +35,8 @@ _require_xfs_io_command "falloc"
 _require_scratch_reflink
 _require_dm_target flakey
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 _mount_flakey
tests/generic/558 +2 -1
index 510b06f2..c6b9e2e0 100755
@@ -34,7 +34,8 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 i=0
tests/generic/559 +1 -1
index 98ab4474..26f07443 100755
@@ -18,7 +18,7 @@ _supported_fs generic
 _require_scratch_duperemove
 
 fssize=$((2 * 1024 * 1024 * 1024))
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # fill the fs with a big file has same contents
tests/generic/562 +2 -1
index 7d98e569..d5a5993b 100755
@@ -21,7 +21,8 @@ _require_scratch_reflink
 _require_test_program "punch-alternating"
 _require_xfs_io_command "fpunch"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 file_size=$(( 200 * 1024 * 1024 )) # 200Mb
tests/generic/619 +1 -1
index c4bdfbce..b844d2f8 100755
@@ -132,7 +132,7 @@ run_testcase()
 
 	for i in $(eval echo "{1..$test_iteration_cnt}"); do
 		# Setup the device
-		_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
+		_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1 || _fail "mkfs failed"
 		_scratch_mount
 
 		debug "===== Test: $test_name iteration: $i starts ====="
tests/generic/626 +2 -1
index 7e577798..afb9322a 100755
@@ -22,7 +22,8 @@ _supported_fs generic
 _require_scratch
 _require_renameat2 whiteout
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create lots of files, to help to trigger the bug easily
tests/generic/679 +2 -1
index ddf975a2..f6e95117 100755
@@ -29,7 +29,8 @@ _supported_fs ^xfs
 rm -f $seqres.full
 
 # Create a 1G filesystem.
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create a file with a size of 600M and two holes, each with a size of 1M and
tests/xfs/075 +1 -1
index ec056fb3..82307e68 100755
@@ -22,7 +22,7 @@ _require_scratch
 _qmount_option "defaults"
 
 echo "Silence is golden"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >$seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >$seqres.full || _fail "mkfs failed"
 
 # first ro mount with norecovery
 _try_scratch_mount "-o ro,norecovery" >>$seqres.full 2>&1 \
tests/xfs/107 +2 -1
index 1ea9c492..c374d15d 100755
@@ -32,7 +32,8 @@ size_mb=256
 # reproduce within the first 500KB's worth of ALLOCSP calls, so running up
 # to 16MB should suffice.
 $XFS_IO_PROG -d -c "pwrite -S 0x58 -b 8m 0 ${size_mb}m" $SCRATCH_DEV > $seqres.full
-MKFS_OPTIONS="-K $MKFS_OPTIONS" _scratch_mkfs_sized $((size_mb * 1048576)) >> $seqres.full
+MKFS_OPTIONS="-K $MKFS_OPTIONS" _scratch_mkfs_sized $((size_mb * 1048576)) \
+	>> $seqres.full || _fail "mkfs failed"
 
 _scratch_mount
 
tests/xfs/118 +2 -1
index 6bb81a3a..f6d17706 100755
@@ -28,7 +28,8 @@ _require_command "$XFS_FSR_PROG" "xfs_fsr"
 _require_xfs_io_command "falloc"
 
 # 50M
-_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "Silence is golden"
tests/xfs/127 +2 -1
index f39b0582..c4237860 100755
@@ -20,7 +20,8 @@ _require_no_large_scratch_dev
 _require_cp_reflink
 
 echo "Format and mount"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/xfs/227 +2 -1
index cd927dc4..0556412c 100755
@@ -122,7 +122,8 @@ create_target_attr_last()
 }
 
 # use a small filesystem so we can control freespace easily
-_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 fragment_freespace
 
tests/xfs/233 +2 -1
index 2b2b8666..dedd1ef8 100755
@@ -18,7 +18,8 @@ _require_xfs_scratch_rmapbt
 _require_no_large_scratch_dev
 
 echo "Format and mount"
-_scratch_mkfs_sized $((2 * 4096 * 4096)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 4096 * 4096)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/xfs/442 +2 -1
index b04b1c83..d55ccc17 100755
@@ -68,7 +68,8 @@ _qmount_option "usrquota,grpquota,prjquota"
 # operations as delalloc for quota accounting") and ("xfs: call
 # xfs_qm_dqattach before performing reflink operations") though each of those
 # tests now have separate faster-running regression tests.
-_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 nr_cpus=$((LOAD_FACTOR * 4))
tests/xfs/529 +2 -1
index cd176877..da4490b7 100755
@@ -29,7 +29,8 @@ _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount -o uquota >> $seqres.full
 
 # bmap_alloc_minlen_extent only applies to the datadev space allocator, so
tests/xfs/532 +2 -1
index 74a7ac30..06e41367 100755
@@ -26,7 +26,8 @@ _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
tests/xfs/534 +2 -1
index f17c45b8..bb940e4a 100755
@@ -22,7 +22,8 @@ _require_xfs_io_command "falloc"
 _require_xfs_io_error_injection "reduce_max_iextents"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 bsize=$(_get_file_block_size $SCRATCH_MNT)
tests/xfs/535 +2 -1
index f76c1725..1c72e3a2 100755
@@ -25,7 +25,8 @@ _require_xfs_io_command "funshare"
 _require_xfs_io_error_injection "reduce_max_iextents"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 bsize=$(_get_block_size $SCRATCH_MNT)
tests/xfs/538 +2 -1
index 0b5772a1..e8ac3918 100755
@@ -23,7 +23,8 @@ _require_test_program "punch-alternating"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
Signature · 1 line
2.35.3
#3 lore raw

Re: [PATCH 2/2] tests: _fail on _scratch_mkfs_sized failure

Quoted 12 lines · Darrick J. Wong
Quoted 6 lines · David Disseldorp

If _scratch_mkfs_sized() fails, e.g. due to an FS not supporting the provided size, tests may subsequently mount and run atop a previously created (e.g. non-size-bound) filesystem.
This can lead to difficult to debug failures, or for some -ENOSPC exercising tests, near infinite runtimes. Avoid this by exiting immediately if _scratch_mkfs_sized() fails.

I wonder, how many tests should keep going if _scratch_mkfs_sized isn't successful? Would it be simpler to make a _try_scratch_mkfs_sized for those callers, and make the main _scratch_mkfs_sized simply do

Quoted 6 lines

_scratch_mkfs_sized()

{
	_try_scratch_mkfs_sized $* || _fail "_scratch_mkfs_sized failed"
}

?

I agree with this. Actually I don't know what's kind of historical reasons make _scratch_mount _fail directly if mount fails, but _scratch_mkfs doesn't like that?

Thanks,
Zorro

Quoted 1,056 lines

--D

Quoted 1,052 lines
---
 tests/btrfs/057   | 3 ++-
 tests/btrfs/132   | 3 ++-
 tests/btrfs/170   | 2 +-
 tests/btrfs/177   | 2 +-
 tests/btrfs/204   | 2 +-
 tests/btrfs/217   | 3 ++-
 tests/btrfs/237   | 1 +
 tests/btrfs/250   | 2 +-
 tests/btrfs/253   | 3 ++-
 tests/ext4/004    | 3 ++-
 tests/ext4/036    | 2 +-
 tests/ext4/038    | 3 ++-
 tests/ext4/039    | 3 ++-
 tests/ext4/048    | 3 ++-
 tests/ext4/050    | 3 ++-
 tests/ext4/271    | 3 ++-
 tests/ext4/307    | 3 ++-
 tests/f2fs/001    | 3 ++-
 tests/generic/027 | 3 ++-
 tests/generic/081 | 3 ++-
 tests/generic/085 | 2 +-
 tests/generic/096 | 3 ++-
 tests/generic/102 | 2 +-
 tests/generic/204 | 2 +-
 tests/generic/224 | 3 ++-
 tests/generic/226 | 3 ++-
 tests/generic/250 | 2 +-
 tests/generic/252 | 2 +-
 tests/generic/256 | 3 ++-
 tests/generic/269 | 3 ++-
 tests/generic/270 | 3 ++-
 tests/generic/273 | 3 ++-
 tests/generic/274 | 3 ++-
 tests/generic/275 | 3 ++-
 tests/generic/300 | 2 +-
 tests/generic/312 | 2 +-
 tests/generic/320 | 2 +-
 tests/generic/333 | 3 ++-
 tests/generic/334 | 3 ++-
 tests/generic/361 | 3 ++-
 tests/generic/371 | 3 ++-
 tests/generic/387 | 3 ++-
 tests/generic/399 | 2 +-
 tests/generic/416 | 2 +-
 tests/generic/427 | 3 ++-
 tests/generic/449 | 3 ++-
 tests/generic/459 | 3 ++-
 tests/generic/488 | 3 ++-
 tests/generic/511 | 3 ++-
 tests/generic/515 | 3 ++-
 tests/generic/520 | 2 +-
 tests/generic/536 | 3 ++-
 tests/generic/546 | 3 ++-
 tests/generic/558 | 3 ++-
 tests/generic/559 | 2 +-
 tests/generic/562 | 3 ++-
 tests/generic/619 | 2 +-
 tests/generic/626 | 3 ++-
 tests/generic/679 | 3 ++-
 tests/xfs/075     | 2 +-
 tests/xfs/107     | 3 ++-
 tests/xfs/118     | 3 ++-
 tests/xfs/127     | 3 ++-
 tests/xfs/227     | 3 ++-
 tests/xfs/233     | 3 ++-
 tests/xfs/442     | 3 ++-
 tests/xfs/529     | 3 ++-
 tests/xfs/532     | 3 ++-
 tests/xfs/534     | 3 ++-
 tests/xfs/535     | 3 ++-
 tests/xfs/538     | 3 ++-
 71 files changed, 122 insertions(+), 70 deletions(-)
tests/btrfs/057 +2 -1
index e932a657..ff002c86 100755
@@ -17,7 +17,8 @@ _supported_fs btrfs
 _require_scratch
 _require_qgroup_rescan
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 _scratch_mount
 
tests/btrfs/132 +2 -1
index f50420f5..b10b8e2a 100755
@@ -35,7 +35,8 @@ _require_scratch
 # to further increase the possibility
 # Since the false ENOSPC happens due to incorrect metadata reservation,
 # larger nodesize and small fs will make it much easier to reproduce
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # Recommended to use MOUNT_OPTIONS="-o compress" to trigger the bug
 _scratch_mount
tests/btrfs/170 +1 -1
index ab105d36..103d097f 100755
@@ -25,7 +25,7 @@ _require_xfs_io_command "falloc" "-k"
 # later want to not have more space available for allocating data extents but
 # still have enough metadata space free for creating the snapshot.
 fs_size=$((2 * 1024 * 1024 * 1024)) # 2Gb
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 
 # Mount without space cache so that we can precisely fill all data space and
 # unallocated space later (space cache v1 uses data block groups).
tests/btrfs/177 +1 -1
index 7b004b83..4de18785 100755
@@ -47,7 +47,7 @@ _require_scratch_size $((3 * 1024 * 1024)) #kB
 
 # First, create a 1GB filesystem.
 fssize=$((1024 * 1024 * 1024))
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create a small file and run balance so we shall deal with the chunk
tests/btrfs/204 +1 -1
index ec751e42..7c036181 100755
@@ -20,7 +20,7 @@ _supported_fs btrfs
 _require_scratch
 _require_xfs_io_command "fpunch"
 
-_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full || _fail "mkfs failed"
 
 # max_inline ensures data is not inlined within metadata extents
 _scratch_mount "-o max_inline=0,nodatacow"
tests/btrfs/217 +2 -1
index 92bbba23..4be154b0 100755
@@ -23,7 +23,8 @@ _require_scratch_size $((5 * 1024 * 1024)) #kB
 _require_fstrim
 
 # Create a 5G fs
-_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Fstrim to populate the device->alloc_status CHUNK_TRIMMED bits
tests/btrfs/237 +1 -0
index 367019b6..823bf18a 100755
@@ -53,6 +53,7 @@ if [[ $devsize -gt $fssize ]]; then
 else
 	_scratch_mkfs >> $seqres.full 2>&1
 fi
+[[ $? -ne 0 ]] && _fail "mkfs failed"
 _scratch_mount -o commit=1 # 1s commit time to speed up test
 
 uuid=$($BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV |grep uuid: |\
tests/btrfs/250 +1 -1
index e7ddc2f1..ab39bfdb 100755
@@ -36,7 +36,7 @@ _require_odirect
 # space available for allocating data extents but still have enough metadata
 # space free for the file writes.
 fs_size=$((1024 * 1024 * 1024)) # 1G
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create our test file with the NOCOW attribute set.
tests/btrfs/253 +2 -1
index 5fbce070..2273e690 100755
@@ -89,7 +89,8 @@ rm -f "${seqres}.full"
 
 # Make filesystem. 10GB is needed to test different chunk sizes for
 # metadata and data and the default size for volumes > 5GB is different.
-_scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # Check if there is sufficient sysfs support.
tests/ext4/004 +2 -1
index 0c2ad897..d23cc547 100755
@@ -54,7 +54,8 @@ _require_command "$RESTORE_PROG" restore
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 rm -rf $restore_dir $TEST_DIR/restoresymtable
 
tests/ext4/036 +1 -1
index 60ab0b90..a4bbe528 100755
@@ -21,7 +21,7 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # create a file and get its inode number, usually it's 12, but to be accurate
tests/ext4/038 +2 -1
index 596de65b..a84d070b 100755
@@ -23,7 +23,8 @@ echo "Silence is golden"
 # it is better to test all reserved inode numbers 1-10 here
 for i in {1..10}; do
 	# create smaller filesystems to save test time
-	_scratch_mkfs_sized $((16 * 1024 * 1024)) >>$seqres.full 2>&1
+	_scratch_mkfs_sized $((16 * 1024 * 1024)) >>$seqres.full 2>&1 \
+		|| _fail "mkfs failed"
 	$DEBUGFS_PROG -w -R "ssv last_orphan $i" $SCRATCH_DEV >>$seqres.full 2>&1
 	_scratch_mount
 	_scratch_unmount
tests/ext4/039 +2 -1
index 4ca4058a..4945bab2 100755
@@ -61,7 +61,8 @@ _supported_fs ext3 ext4
 _require_scratch
 _exclude_scratch_mount_option dax
 
-_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 if ! _workout; then
tests/ext4/048 +2 -1
index c23c0ea3..a499038e 100755
@@ -81,7 +81,8 @@ test_file1="test0001"
 test_file2="test0002"
 test_file3="test0003"
 
-_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # create scratch dir for testing
 # create some files with no name a substr of another name so we can grep later
tests/ext4/050 +2 -1
index 6f93b86d..95326771 100755
@@ -24,7 +24,8 @@ _require_test_program "checkpoint_journal"
 
 testdir="${SCRATCH_MNT}/testdir"
 
-_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _scratch_mount >> $seqres.full 2>&1
 blocksize=$(_get_block_size $SCRATCH_MNT)
tests/ext4/271 +2 -1
index 8d9bd7dc..feceb7f3 100755
@@ -20,7 +20,8 @@ _require_scratch
 _exclude_scratch_mount_option "data" "commit" "journal_checksum" \
 			      "journal_async_commit"
 
-_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # -onoload and EXT4_SYNC_FL on file is important becase result in
 # metadata sync writes inside ext4_handle_dirty_metadata()
tests/ext4/307 +2 -1
index 8b1cfc9e..b63e1e91 100755
@@ -41,7 +41,8 @@ _require_scratch
 _require_defrag
 _require_xfs_io_command "falloc"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 _workout
tests/f2fs/001 +2 -1
index 2bf39d8c..4c7d7c7a 100755
@@ -29,7 +29,8 @@ testfile=$SCRATCH_MNT/testfile
 dummyfile=$SCRATCH_MNT/dummyfile
 
 # build 4GB filesystem
-_scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1
+_scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "==== create small file ===="
tests/generic/027 +2 -1
index 47f1981d..a8689a15 100755
@@ -35,7 +35,8 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "Reserve 2M space" >>$seqres.full
tests/generic/081 +2 -1
index 0996f221..71ef19e0 100755
@@ -67,7 +67,8 @@ lvsize=$((size * 85 / 100))	 # ~256M
 
 # make sure there's enough disk space for 256M lv, test for 300M here in case
 # lvm uses some space for metadata
-_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
 # (like 2.02.95 in RHEL6) don't support --yes option
tests/generic/085 +1 -1
index 786d8e6f..7e501cf8 100755
@@ -52,7 +52,7 @@ echo "Silence is golden"
 
 size=$((256 * 1024 * 1024))
 size_in_sector=$((size / 512))
-_scratch_mkfs_sized $size >>$seqres.full 2>&1
+_scratch_mkfs_sized $size >>$seqres.full 2>&1 || _fail "mkfs failed"
 
 node=$seq-test
 lvdev=/dev/mapper/$node
tests/generic/096 +2 -1
index 41b646c0..d76b2f53 100755
@@ -23,7 +23,8 @@ _require_xfs_io_command "fzero"
 echo "Silence is golden"
 
 # Use smaller scratch fs to shorten the test time
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 testfile=$SCRATCH_MNT/$seq.$$
tests/generic/102 +1 -1
index 3536ebf7..396cb80c 100755
@@ -23,7 +23,7 @@ _supported_fs generic
 _require_scratch
 
 dev_size=$((1024 * 1024 * 1024))     # 1GB filesystem
-_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 for ((i = 0; i < 10; i++)); do
tests/generic/204 +1 -1
index a33a090f..31b920f2 100755
@@ -31,7 +31,7 @@ _require_scratch
 [ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=16m -i maxpct=50"
 
 SIZE=`expr 115 \* 1024 \* 1024`
-_scratch_mkfs_sized $SIZE 2> /dev/null > $tmp.mkfs.raw
+_scratch_mkfs_sized $SIZE 2> /dev/null > $tmp.mkfs.raw || _fail "mkfs failed"
 cat $tmp.mkfs.raw | _filter_mkfs 2> $tmp.mkfs > /dev/null
 _scratch_mount
 
tests/generic/224 +2 -1
index 26055ea2..6407aed0 100755
@@ -30,7 +30,8 @@ _supported_fs generic
 _require_scratch
 
 # make a 1GB filesystem
-_scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1
+_scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # set the reserved block pool to almost empty for XFS
tests/generic/226 +2 -1
index 34434730..5b0d5088 100755
@@ -19,7 +19,8 @@ _require_odirect
 
 _scratch_unmount 2>/dev/null
 echo "--> mkfs 256m filesystem"
-_scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1
+_scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 loops=16
tests/generic/250 +1 -1
index 97e9522f..b4b98ad2 100755
@@ -35,7 +35,7 @@ unset SCRATCH_RTDEV
 fssize=$((196 * 1048576))
 echo "Format and mount"
 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 _dmerror_unmount
tests/generic/252 +1 -1
index 8c5adb53..6108183b 100755
@@ -36,7 +36,7 @@ unset SCRATCH_RTDEV
 fssize=$((196 * 1048576))
 echo "Format and mount"
 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 _dmerror_unmount
tests/generic/256 +2 -1
index ea6cc293..aa72a2a4 100755
@@ -89,7 +89,8 @@ _test_full_fs_punch()
 
 # Make a small file system to fill
 _scratch_unmount &> /dev/null
-_scratch_mkfs_sized $(( 1536 * 1024 * 1024 )) &> /dev/null
+_scratch_mkfs_sized $(( 1536 * 1024 * 1024 )) &> /dev/null \
+	|| _fail "mkfs failed"
 _scratch_mount
 # Test must be able to write files with non-root permissions
 chmod 777 $SCRATCH_MNT
tests/generic/269 +2 -1
index b7cdecd9..c10bc908 100755
@@ -42,7 +42,8 @@ _workout()
 _supported_fs generic
 _require_scratch
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 if ! _workout; then
tests/generic/270 +2 -1
index e7329c2f..3c495a5d 100755
@@ -61,7 +61,8 @@ _require_command "$KILLALL_PROG" killall
 _require_command "$SETCAP_PROG" setcap
 _require_attrs security
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount "-o usrquota,grpquota"
 chmod 777 $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
tests/generic/273 +2 -1
index 54c19996..53e18be7 100755
@@ -125,7 +125,8 @@ echo "start the workload"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 _do_workload
tests/generic/274 +2 -1
index 8c0e420e..ee1f71ea 100755
@@ -39,7 +39,8 @@ echo "preallocation test"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create a 4k file and Allocate 4M past EOF on that file
tests/generic/275 +2 -1
index f3b05409..effaee63 100755
@@ -34,7 +34,8 @@ echo "write until ENOSPC test"
 echo "------------------------------"
 
 _scratch_unmount 2>/dev/null
-_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Certain filesystems such as XFS require sufficient free blocks to handle the
tests/generic/300 +1 -1
index 5ff141d3..fea951c3 100755
@@ -110,7 +110,7 @@ EOF
 
 _require_fio $fio_config
 
-_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
+_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 echo ""
tests/generic/312 +1 -1
index 1926deb8..03ddd7c5 100755
@@ -23,7 +23,7 @@ _require_scratch
 # 5G in byte
 fssize=$((2**30 * 5))
 
-_scratch_mkfs_sized $fssize >>$seqres.full 2>&1
+_scratch_mkfs_sized $fssize >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >>$seqres.full 2>&1
 
 echo "Silence is golden"
tests/generic/320 +1 -1
index ea65537f..15178435 100755
@@ -79,7 +79,7 @@ do_workload()
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >>$seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >>$seqres.full 2>&1
 
 do_workload
tests/generic/333 +2 -1
index bf1967ce..fad4e357 100755
@@ -30,7 +30,8 @@ _require_cp_reflink
 _require_odirect
 
 echo "Format and mount"
-_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/generic/334 +2 -1
index b9c14b87..f78641d6 100755
@@ -29,7 +29,8 @@ _require_scratch_reflink
 _require_cp_reflink
 
 echo "Format and mount"
-_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/generic/361 +2 -1
index d76d2635..2ba49e9c 100755
@@ -33,7 +33,8 @@ _require_loop
 _require_sparse_files
 
 # create a small filesystem to hold another filesystem image
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # create the sparse fs image and mount point
tests/generic/371 +2 -1
index a2fdaf7b..8861dc40 100755
@@ -20,7 +20,8 @@ _require_scratch
 _require_xfs_io_command "falloc"
 test "$FSTYP" = "xfs" && _require_xfs_io_command "extsize"
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Disable speculative post-EOF preallocation on XFS, which can grow fast enough
tests/generic/387 +2 -1
index 25ca86bb..0ee01594 100755
@@ -19,7 +19,8 @@ _supported_fs generic
 _require_scratch_reflink
 
 #btrfs needs 256mb to create default blockgroup fs
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 testfile=$SCRATCH_MNT/testfile
tests/generic/399 +1 -1
index a5aa7107..dc42d5c8 100755
@@ -42,7 +42,7 @@ fs_size_in_mb=64
 fs_size=$((fs_size_in_mb * 1024 * 1024))
 dd if=/dev/zero of=$SCRATCH_DEV bs=$((1024 * 1024)) \
 	count=$fs_size_in_mb &>> $seqres.full
-_scratch_mkfs_sized_encrypted $fs_size &>> $seqres.full
+_scratch_mkfs_sized_encrypted $fs_size &>> $seqres.full || _fail "mkfs failed"
 _scratch_mount
 
 keydesc=$(_generate_session_encryption_key)
tests/generic/416 +1 -1
index 0f6e3bc9..b0ce71c9 100755
@@ -28,7 +28,7 @@ page_size=$(_get_page_size)
 nr_files=$(($fs_size / $page_size))
 
 # Use small fs to make the fill more faster
-_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
+_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
 
 _scratch_mount
 
tests/generic/427 +2 -1
index 26385d36..01df59b1 100755
@@ -27,7 +27,8 @@ _require_aiodio aio-dio-eof-race
 _require_no_compress
 
 # limit the filesystem size, to save the time of filling filesystem
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # try to write more bytes than filesystem size to fill the filesystem,
tests/generic/449 +2 -1
index 2b77a6a4..916d1985 100755
@@ -24,7 +24,8 @@ _require_test
 _require_acls
 _require_attrs trusted
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount || _fail "mount failed"
 
 # This is a test of xattr behavior when we run out of disk space for xattrs,
tests/generic/459 +2 -1
index c3f0b2b0..57cd0c52 100755
@@ -76,7 +76,8 @@ is_shutdown_or_ro()
 }
 
 # Ensure we have enough disk space
-_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 
 # Create a 200MB dm-thin POOL
 $LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
tests/generic/488 +2 -1
index 7b9dcc18..26f08040 100755
@@ -16,7 +16,8 @@ _supported_fs generic
 _require_scratch
 _require_test_program "multi_open_unlink"
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 test_file="$SCRATCH_MNT/$seq"
tests/generic/511 +2 -1
index 61c21e42..d96d46df 100755
@@ -19,7 +19,8 @@ _require_scratch
 _require_xfs_io_command "falloc" "-k"
 _require_xfs_io_command "fzero"
 
-_scratch_mkfs_sized $((1024 * 1024 * 256)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 256)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 $XFS_IO_PROG -fc "pwrite 0 256m" -c fsync $SCRATCH_MNT/file >>$seqres.full 2>&1
tests/generic/515 +2 -1
index 1d537dec..0b14f9e3 100755
@@ -24,7 +24,8 @@ _require_xfs_io_command "falloc"
 # Fill disk with a well known pattern so that stale data exposure becomes much
 # more obvious.
 $XFS_IO_PROG -c "pwrite -S 0x58 -b 1m 0 300m" $SCRATCH_DEV >> $seqres.full
-_scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 DONOR1=$SCRATCH_MNT/a
tests/generic/520 +1 -1
index ad6764c7..9bf2a6eb 100755
@@ -33,7 +33,7 @@ _require_scratch_nocheck
 _require_dm_target flakey
 
 # initialize scratch device
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 
tests/generic/536 +2 -1
index 986ea1ee..3ff56914 100755
@@ -21,7 +21,8 @@ _require_scratch
 _require_scratch_shutdown
 
 # create a small fs and initialize free blocks with a unique pattern
-_scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 100m" -c fsync $SCRATCH_MNT/spc \
 	>> $seqres.full 2>&1
tests/generic/546 +2 -1
index 2eb99543..75de5478 100755
@@ -35,7 +35,8 @@ _require_xfs_io_command "falloc"
 _require_scratch_reflink
 _require_dm_target flakey
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _require_metadata_journaling $SCRATCH_DEV
 _init_flakey
 _mount_flakey
tests/generic/558 +2 -1
index 510b06f2..c6b9e2e0 100755
@@ -34,7 +34,8 @@ _require_scratch
 
 echo "Silence is golden"
 
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 i=0
tests/generic/559 +1 -1
index 98ab4474..26f07443 100755
@@ -18,7 +18,7 @@ _supported_fs generic
 _require_scratch_duperemove
 
 fssize=$((2 * 1024 * 1024 * 1024))
-_scratch_mkfs_sized $fssize > $seqres.full 2>&1
+_scratch_mkfs_sized $fssize > $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 # fill the fs with a big file has same contents
tests/generic/562 +2 -1
index 7d98e569..d5a5993b 100755
@@ -21,7 +21,8 @@ _require_scratch_reflink
 _require_test_program "punch-alternating"
 _require_xfs_io_command "fpunch"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 file_size=$(( 200 * 1024 * 1024 )) # 200Mb
tests/generic/619 +1 -1
index c4bdfbce..b844d2f8 100755
@@ -132,7 +132,7 @@ run_testcase()
 
 	for i in $(eval echo "{1..$test_iteration_cnt}"); do
 		# Setup the device
-		_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
+		_scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1 || _fail "mkfs failed"
 		_scratch_mount
 
 		debug "===== Test: $test_name iteration: $i starts ====="
tests/generic/626 +2 -1
index 7e577798..afb9322a 100755
@@ -22,7 +22,8 @@ _supported_fs generic
 _require_scratch
 _require_renameat2 whiteout
 
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create lots of files, to help to trigger the bug easily
tests/generic/679 +2 -1
index ddf975a2..f6e95117 100755
@@ -29,7 +29,8 @@ _supported_fs ^xfs
 rm -f $seqres.full
 
 # Create a 1G filesystem.
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 # Create a file with a size of 600M and two holes, each with a size of 1M and
tests/xfs/075 +1 -1
index ec056fb3..82307e68 100755
@@ -22,7 +22,7 @@ _require_scratch
 _qmount_option "defaults"
 
 echo "Silence is golden"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >$seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >$seqres.full || _fail "mkfs failed"
 
 # first ro mount with norecovery
 _try_scratch_mount "-o ro,norecovery" >>$seqres.full 2>&1 \
tests/xfs/107 +2 -1
index 1ea9c492..c374d15d 100755
@@ -32,7 +32,8 @@ size_mb=256
 # reproduce within the first 500KB's worth of ALLOCSP calls, so running up
 # to 16MB should suffice.
 $XFS_IO_PROG -d -c "pwrite -S 0x58 -b 8m 0 ${size_mb}m" $SCRATCH_DEV > $seqres.full
-MKFS_OPTIONS="-K $MKFS_OPTIONS" _scratch_mkfs_sized $((size_mb * 1048576)) >> $seqres.full
+MKFS_OPTIONS="-K $MKFS_OPTIONS" _scratch_mkfs_sized $((size_mb * 1048576)) \
+	>> $seqres.full || _fail "mkfs failed"
 
 _scratch_mount
 
tests/xfs/118 +2 -1
index 6bb81a3a..f6d17706 100755
@@ -28,7 +28,8 @@ _require_command "$XFS_FSR_PROG" "xfs_fsr"
 _require_xfs_io_command "falloc"
 
 # 50M
-_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 
 echo "Silence is golden"
tests/xfs/127 +2 -1
index f39b0582..c4237860 100755
@@ -20,7 +20,8 @@ _require_no_large_scratch_dev
 _require_cp_reflink
 
 echo "Format and mount"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((512 * 1024 * 1024)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/xfs/227 +2 -1
index cd927dc4..0556412c 100755
@@ -122,7 +122,8 @@ create_target_attr_last()
 }
 
 # use a small filesystem so we can control freespace easily
-_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount
 fragment_freespace
 
tests/xfs/233 +2 -1
index 2b2b8666..dedd1ef8 100755
@@ -18,7 +18,8 @@ _require_xfs_scratch_rmapbt
 _require_no_large_scratch_dev
 
 echo "Format and mount"
-_scratch_mkfs_sized $((2 * 4096 * 4096)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((2 * 4096 * 4096)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
tests/xfs/442 +2 -1
index b04b1c83..d55ccc17 100755
@@ -68,7 +68,8 @@ _qmount_option "usrquota,grpquota,prjquota"
 # operations as delalloc for quota accounting") and ("xfs: call
 # xfs_qm_dqattach before performing reflink operations") though each of those
 # tests now have separate faster-running regression tests.
-_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1
+_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1 \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full 2>&1
 
 nr_cpus=$((LOAD_FACTOR * 4))
tests/xfs/529 +2 -1
index cd176877..da4490b7 100755
@@ -29,7 +29,8 @@ _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount -o uquota >> $seqres.full
 
 # bmap_alloc_minlen_extent only applies to the datadev space allocator, so
tests/xfs/532 +2 -1
index 74a7ac30..06e41367 100755
@@ -26,7 +26,8 @@ _require_xfs_io_error_injection "reduce_max_iextents"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
tests/xfs/534 +2 -1
index f17c45b8..bb940e4a 100755
@@ -22,7 +22,8 @@ _require_xfs_io_command "falloc"
 _require_xfs_io_error_injection "reduce_max_iextents"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 bsize=$(_get_file_block_size $SCRATCH_MNT)
tests/xfs/535 +2 -1
index f76c1725..1c72e3a2 100755
@@ -25,7 +25,8 @@ _require_xfs_io_command "funshare"
 _require_xfs_io_error_injection "reduce_max_iextents"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 bsize=$(_get_block_size $SCRATCH_MNT)
tests/xfs/538 +2 -1
index 0b5772a1..e8ac3918 100755
@@ -23,7 +23,8 @@ _require_test_program "punch-alternating"
 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
 
 echo "Format and mount fs"
-_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
+_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full \
+	|| _fail "mkfs failed"
 _scratch_mount >> $seqres.full
 
 # Disable realtime inherit flag (if any) on root directory so that space on data
Signature · 1 line
2.35.3
#4 lore raw

Re: [PATCH 2/2] tests: _fail on _scratch_mkfs_sized failure

Quoted 9 lines · Zorro Lang
Quoted 9 lines

I wonder, how many tests should keep going if _scratch_mkfs_sized isn't successful? Would it be simpler to make a _try_scratch_mkfs_sized for those callers, and make the main _scratch_mkfs_sized simply do

_scratch_mkfs_sized()

{
	_try_scratch_mkfs_sized $* || _fail "_scratch_mkfs_sized failed"
}
Quoted 5 lines
Quoted 1 line

?

I agree with this. Actually I don't know what's kind of historical reasons make _scratch_mount _fail directly if mount fails, but _scratch_mkfs doesn't like that?

Agreed. Unsupported mkfs should absolutely fail by default. For some tests instead of _fail it should be _notsupported, but that would be a separate helper and between the two of them we'd cover almost all uses.

Reviewed-by on v1 1/2
#5 lore raw
In reply to David Disseldorp
Quoted 20 lines · David Disseldorp

As of xfsprogs commit 6e0ed3d1 ("mkfs: stop allowing tiny filesystems") attempts to create XFS filesystems sized under 300M fail, unless TEST_DIR, TEST_DEV and QA_CHECK_FS environment variables are exported (or a --unsupported mkfs parameter is provided).

TEST_DIR and QA_CHECK_FS are already exported, while TEST_DEV may only be locally set if provided via e.g. configs/$HOSTNAME.config. Explicitly export TEST_DEV to ensure that tests which call _scratch_mkfs_sized() with an fssize under 300M run normally.

---
 common/config | 3 +++
 1 file changed, 3 insertions(+)
common/config +0 -0
index 2a1434bb..4bd5650f 100644

common/config else · line 937

Quoted 6 lines
common/config +3 -0
@@ -932,6 +932,9 @@ else
 fi
 
 _canonicalize_devices
+# mkfs.xfs checks for TEST_DEV before permitting < 300M filesystems. TEST_DIR
+# and QA_CHECK_FS are also checked by mkfs.xfs, but already exported elsewhere.
+export TEST_DEV

I wonder if we only ought to do this for $FSTYP = xfs, but I don't have a problem with this so

--D

Quoted 7 lines
common/config +0 -0
 # make sure this script returns success
 /bin/true
Signature · 1 line
2.35.3
Reviewed-by on v1 1/2
#6 lore raw
In reply to David Disseldorp
Quoted 9 lines · David Disseldorp

As of xfsprogs commit 6e0ed3d1 ("mkfs: stop allowing tiny filesystems") attempts to create XFS filesystems sized under 300M fail, unless TEST_DIR, TEST_DEV and QA_CHECK_FS environment variables are exported (or a --unsupported mkfs parameter is provided).

TEST_DIR and QA_CHECK_FS are already exported, while TEST_DEV may only be locally set if provided via e.g. configs/$HOSTNAME.config. Explicitly export TEST_DEV to ensure that tests which call _scratch_mkfs_sized() with an fssize under 300M run normally.

As for fixing the immediate problem this looks fine:

But adding the xfs list as allowing to create a smaller than supported file system just for testing is pretty silly. If we don't want to support these tiny file systems, we should also not use them for testing. The best way to port over the existing tests to a larger size would probably be to round up the size to the minimum supported one and then fill the space?

#7 lore raw
In reply to David Disseldorp
Quoted 5 lines · David Disseldorp

As of xfsprogs commit 6e0ed3d1 ("mkfs: stop allowing tiny filesystems") attempts to create XFS filesystems sized under 300M fail, unless TEST_DIR, TEST_DEV and QA_CHECK_FS environment variables are exported (or a --unsupported mkfs parameter is provided).

Quoted 7 lines

TEST_DIR and QA_CHECK_FS are already exported, while TEST_DEV may only be locally set if provided via e.g. configs/$HOSTNAME.config. Explicitly export TEST_DEV to ensure that tests which call _scratch_mkfs_sized() with an fssize under 300M run normally.

---

Actually, using "export" in xfstests/local.config for each parameter could help too.

The 2nd patch still has some disagreement, I'll merge this patch at first, as it's simple enough and got two RVBs.

Thanks,
Zorro

Quoted 21 lines
 common/config | 3 +++
 1 file changed, 3 insertions(+)
common/config +3 -0
index 2a1434bb..4bd5650f 100644
@@ -932,6 +932,9 @@ else
 fi
 
 _canonicalize_devices
+# mkfs.xfs checks for TEST_DEV before permitting < 300M filesystems. TEST_DIR
+# and QA_CHECK_FS are also checked by mkfs.xfs, but already exported elsewhere.
+export TEST_DEV
 
 # make sure this script returns success
 /bin/true
Signature · 1 line
2.35.3
#8 lore raw
Quoted 11 lines · Zorro Lang
Quoted 10 lines · David Disseldorp

As of xfsprogs commit 6e0ed3d1 ("mkfs: stop allowing tiny filesystems") attempts to create XFS filesystems sized under 300M fail, unless TEST_DIR, TEST_DEV and QA_CHECK_FS environment variables are exported (or a --unsupported mkfs parameter is provided).

TEST_DIR and QA_CHECK_FS are already exported, while TEST_DEV may only be locally set if provided via e.g. configs/$HOSTNAME.config. Explicitly export TEST_DEV to ensure that tests which call _scratch_mkfs_sized() with an fssize under 300M run normally.

Quoted 8 lines
Quoted 2 lines

---

Actually, using "export" in xfstests/local.config for each parameter could help too.

The 2nd patch still has some disagreement, I'll merge this patch at first, as it's simple enough and got two RVBs.

Thanks. I'll send an updated 2/2 today following Darrick's suggestion of _try_scratch_mkfs_sized $* || _fail

#9 lore raw
Quoted 16 lines · David Disseldorp
Quoted 14 lines · Zorro Lang
Quoted 12 lines · David Disseldorp

As of xfsprogs commit 6e0ed3d1 ("mkfs: stop allowing tiny filesystems") attempts to create XFS filesystems sized under 300M fail, unless TEST_DIR, TEST_DEV and QA_CHECK_FS environment variables are exported (or a --unsupported mkfs parameter is provided).

TEST_DIR and QA_CHECK_FS are already exported, while TEST_DEV may only be locally set if provided via e.g. configs/$HOSTNAME.config. Explicitly export TEST_DEV to ensure that tests which call _scratch_mkfs_sized() with an fssize under 300M run normally.

---

Quoted 8 lines
Quoted 5 lines

Actually, using "export" in xfstests/local.config for each parameter could help too.

The 2nd patch still has some disagreement, I'll merge this patch at first, as it's simple enough and got two RVBs.

Thanks. I'll send an updated 2/2 today following Darrick's suggestion of _try_scratch_mkfs_sized $* || _fail

Thanks for doing it :)

I'm wondering if we could change all _scratch_mkfs and _scratch_mkfs_xxx helpers like that. But we can change _scratch_mkfs_sized at first, then other _scratch_mkfs_xxx helpers, then _scratch_mkfs itself.

At the same time, please don't forgot those cases do "_scratch_mkfs_xxx ... | _fail ...".

Thanks,
Zorro

Quoted 1 line