diff mbox series

[15/16] fuzzy: allow substitution of AG numbers when configuring scrub stress test

Message ID 167243837501.694541.13900520713966204152.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series fstests: refactor online fsck stress tests | expand

Commit Message

Darrick J. Wong Dec. 30, 2022, 10:12 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Allow the test program to use the metavariable '%agno%' when passing
scrub commands to the scrub stress loop.  This makes it easier for tests
to scrub or repair every AG in the filesystem without a lot of work.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/fuzzy  |   14 ++++++++++++--
 tests/xfs/422 |    2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/common/fuzzy b/common/fuzzy
index 219dd3bb0a..e42e2ccec1 100644
--- a/common/fuzzy
+++ b/common/fuzzy
@@ -368,10 +368,19 @@  __stress_one_scrub_loop() {
 	local runningfile="$2"
 	local scrub_tgt="$3"
 	shift; shift; shift
+	local agcount="$(_xfs_mount_agcount $SCRATCH_MNT)"
 
 	local xfs_io_args=()
 	for arg in "$@"; do
-		xfs_io_args+=('-c' "$arg")
+		if echo "$arg" | grep -q -w '%agno%'; then
+			# Substitute the AG number
+			for ((agno = 0; agno < agcount; agno++)); do
+				local ag_arg="$(echo "$arg" | sed -e "s|%agno%|$agno|g")"
+				xfs_io_args+=('-c' "$ag_arg")
+			done
+		else
+			xfs_io_args+=('-c' "$arg")
+		fi
 	done
 
 	while __stress_scrub_running "$end" "$runningfile"; do
@@ -481,7 +490,8 @@  __stress_scrub_check_commands() {
 	shift
 
 	for arg in "$@"; do
-		testio=`$XFS_IO_PROG -x -c "$arg" $scrub_tgt 2>&1`
+		local cooked_arg="$(echo "$arg" | sed -e "s/%agno%/0/g")"
+		testio=`$XFS_IO_PROG -x -c "$cooked_arg" $scrub_tgt 2>&1`
 		echo $testio | grep -q "Unknown type" && \
 			_notrun "xfs_io scrub subcommand support is missing"
 		echo $testio | grep -q "Inappropriate ioctl" && \
diff --git a/tests/xfs/422 b/tests/xfs/422
index ac88713257..995f612166 100755
--- a/tests/xfs/422
+++ b/tests/xfs/422
@@ -31,7 +31,7 @@  _require_xfs_stress_online_repair
 _scratch_mkfs > "$seqres.full" 2>&1
 _scratch_mount
 _require_xfs_has_feature "$SCRATCH_MNT" rmapbt
-_scratch_xfs_stress_online_repair -f -s "repair rmapbt 0" -s "repair rmapbt 1"
+_scratch_xfs_stress_online_repair -f -s "repair rmapbt %agno%"
 
 # success, all done
 echo Silence is golden