[PATCH v1 7/7] xfs: Add parallel back to back grow/shrink tests

Nirjhar Roy (IBM)
2026-02-19T06:12:13Z

From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>

This test makes several parallel back to back shrink/grow requests and
makes sure that at the end of all operations, the filesystem is in a
consistent state with no corruptions and crashes.

Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
tests/xfs/611 | 97 +++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/611.out | 5 +++
2 files changed, 102 insertions(+)
create mode 100755 tests/xfs/611
create mode 100644 tests/xfs/611.out

diff --git a/tests/xfs/611 b/tests/xfs/611
new file mode 100755
index 00000000..67f1d92f
--- /dev/null
+++ b/tests/xfs/611
@@ -0,0 +1,97 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>. All Rights Reserved.
+#
+# FS QA Test 611
+#
+# It creates NUM_PROCS number of processes. Some will pass, some will fail
+# with:
+# a) operation in progress
+# b) no space available
+# c) size unchanged.
+# All the back to back xfs_growfs requests are made without recreating the
+# filesystem in between 2 consecutive requests. This test ensures that even
+# after several grow/shrink requests, the filesystem is in a consistent state
+# and there are no crashes or metadata corruptions.
+
+. ./common/preamble
+_begin_fstest auto quick growfs shrinkfs
+
+. ./common/filter
+_require_realtime_xfs_shrink
+
+AGCOUNT=16
+RGCOUNT="$AGCOUNT"
+FSSIZE=$(( 2 * 1024 * 1024 * 1024 )) # 2G
+NUM_LOOP=500
+NUM_PROCS=$(( 4 * LOAD_FACTOR ))
+_require_scratch_size $(( FSSIZE / 1024 )) #KB
+
+_fixed_by_kernel_commit a65fd8120766 "xfs: Fix xfs_grow_last_rtg()"
+_fixed_by_kernel_commit xxxxxxxxxxxx "xfs: Fix in xfs_rtalloc_query_range()"
+
+_stress_scratch()
+{
+ procs=4
+ nops=9999
+ # -w ensures that the only ops are ones which cause write I/O
+ FSSTRESS_ARGS=`_scale_fsstress_args -d $SCRATCH_MNT -w -p $procs \
+ -n $nops`
+ _run_fsstress_bg $FSSTRESS_ARGS >> $seqres.full 2>&1
+}
+
+setup()
+{
+ _scratch_unmount $SCRATCH_MNT >> $seqres.full 2>&1
+ _scratch_mkfs -bsize=4k -dsize="$FSSIZE" -dagcount="$AGCOUNT" -rsize="$FSSIZE"\
+ -mmetadir="$1" -rrgcount="$RGCOUNT" 2>&1 | \
+ tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs >/dev/null
+ . $tmp.mkfs
+ _scratch_mount >> $seqres.full
+ RGSZ=$(( FSSIZE / (dbsize * RGCOUNT) ))
+}
+
+run_loop() {
+ for ((i=0; i<"$NUM_LOOP"; i++)); do
+ numag=$(( RANDOM % 17 ))
+ nblocksag=$(( numag * RGSZ ))
+ numblksoff=$(( RANDOM % RGSZ ))
+ nblkstot=$(( nblocksag + numblksoff ))
+ $XFS_GROWFS_PROG -R "$nblkstot" $SCRATCH_MNT >> $seqres.full 2>&1
+ done
+}
+
+start_test()
+{
+ for ((j=0; j<"$NUM_PROCS"; j++)); do
+ run_loop "$j" &
+ done
+ if [[ "$1" -eq 1 ]]; then
+ _stress_scratch
+ fi
+}
+
+# We want to test with and without stress. The reason is that, if stress
+# fills up the filesystem such that all the rtgs are non-empty, then all
+# the shrink commands will fail and we won't be able to test. So to cover all
+# the types of scenarios, we are testing with and without stress.
+for stress in 0 1
+do
+ for metadir in 1 0
+ do
+ setup "$metadir" "$stress"
+ if [[ "$stress" -eq 1 ]]; then
+ echo -n "Testing with stress"
+ else
+ echo -n "Testing without stress"
+ fi
+ echo -n " with -m metadir=$metadir "
+
+ start_test "$stress"
+ wait
+ _check_scratch_fs
+ echo "succeeded"
+ done
+done
+# success, all done
+_exit 0
diff --git a/tests/xfs/611.out b/tests/xfs/611.out
new file mode 100644
index 00000000..21f0c43b
--- /dev/null
+++ b/tests/xfs/611.out
@@ -0,0 +1,5 @@
+QA output created by 611
+Testing without stress with -m metadir=1 succeeded
+Testing without stress with -m metadir=0 succeeded
+Testing with stress with -m metadir=1 succeeded
+Testing with stress with -m metadir=0 succeeded
--
2.34.1