FS/XFS testing framework
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Zorro Lang <zlang@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
	fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 12/13] xfs/2307: test checksum handling using corrupted checksums
Date: Thu, 24 Sep 2026 12:07:53 +0200	[thread overview]
Message-ID: <20260924100855.2734089-13-hch@lst.de> (raw)
In-Reply-To: <20260924100855.2734089-1-hch@lst.de>

Inject errors into the rtcsum files and check that the kernel handles
them gracefully and that repair fixes them, rebuilding the checksums if
needed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/xfs/2307     | 106 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/2307.out |  93 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 199 insertions(+)
 create mode 100755 tests/xfs/2307
 create mode 100644 tests/xfs/2307.out

diff --git a/tests/xfs/2307 b/tests/xfs/2307
new file mode 100755
index 000000000000..47d5be36623d
--- /dev/null
+++ b/tests/xfs/2307
@@ -0,0 +1,106 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2026 Christoph Hellwig.
+#
+# FS QA Test No. 2307
+#
+# Inject errors into the rtcsum files and check that the kernel handles
+# them gracefully and that repair fixes them, rebuilding the checksums if
+# needed.
+#
+. ./common/preamble
+_begin_fstest auto quick repair zone datacsum
+
+. ./common/filter
+. ./common/repair
+
+_require_scratch_nocheck
+
+
+prepare_fs()
+{
+	_scratch_mkfs >> $seqres.full 2>&1
+	_scratch_mount
+	_require_xfs_data_csum $TEST_DIR
+	cat /bin/sh > $SCRATCH_MNT/sh
+	_scratch_unmount
+}
+
+exercise_repair()
+{
+	echo "Checking corrupted file system"
+	_scratch_xfs_repair -P -n >> $seqres.full 2>&1
+
+	echo "Repairing corrupted file system"
+	_scratch_xfs_repair -P >> $seqres.full 2>&1
+}
+
+check_corrupted()
+{
+	echo "Checking corrupted file system"
+	_scratch_xfs_repair -P -n >> $seqres.full 2>&1
+	if [ $? -eq 0 ]; then
+		_fail "xfs_repair -n succeeded"
+	fi
+
+	_scratch_mount
+
+	echo "Reading from corrupted file system"
+	cmp /bin/sh $SCRATCH_MNT/sh
+	_scratch_unmount
+}
+
+check_fixed()
+{
+	echo "Checking repaired file system"
+	_scratch_xfs_repair -P -n 2>&1 | _filter_repair
+
+	_scratch_mount
+
+	echo "Scrubbing repaired file system"
+	$XFS_SCRUB_PROG -x -a 0 $SCRATCH_MNT >> $seqres.full
+	if [ $? -ne 0 ]; then
+		_fail "xfs_scrub failed"
+	fi
+
+	echo "Reading from repaired file system"
+	cmp /bin/sh $SCRATCH_MNT/sh
+	_scratch_unmount
+}
+
+echo
+echo
+echo "Corrupting rtcsum inode size"
+echo
+prepare_fs
+_scratch_xfs_set_metadata_field core.size 18 "path -m /rtgroups/0.csum"
+check_corrupted
+exercise_repair
+check_fixed
+
+echo
+echo
+echo "Corrupting rtcsum inode mode"
+echo
+prepare_fs
+_scratch_xfs_set_metadata_field core.mode 0 "path -m /rtgroups/0.csum"
+if _try_scratch_mount >>$seqres.full 2>&1; then
+	_fail "mount succeeded with corrupted nextents"
+fi
+exercise_repair
+check_fixed
+
+echo
+echo
+echo "Corrupting rtcsum inode nextents"
+echo
+prepare_fs
+_scratch_xfs_set_metadata_field core.nextents 2 "path -m /rtgroups/0.csum"
+if _try_scratch_mount >>$seqres.full 2>&1; then
+	_fail "mount succeeded with corrupted nextents"
+fi
+exercise_repair
+check_fixed
+
+status=0
+exit
diff --git a/tests/xfs/2307.out b/tests/xfs/2307.out
new file mode 100644
index 000000000000..2016c27ee280
--- /dev/null
+++ b/tests/xfs/2307.out
@@ -0,0 +1,93 @@
+QA output created by 2307
+
+
+Corrupting rtcsum inode size
+
+Allowing write of corrupted data with good CRC
+core.size = 18
+Checking corrupted file system
+Reading from corrupted file system
+Checking corrupted file system
+Repairing corrupted file system
+Checking repaired file system
+Phase 1 - find and verify superblock...
+Phase 2 - using <TYPEOF> log
+        - zero log...
+        - scan filesystem freespace and inode maps...
+        - found root inode chunk
+Phase 3 - for each AG...
+        - scan (but don't clear) agi unlinked lists...
+        - process known inodes and perform inode discovery...
+        - process newly discovered inodes...
+Phase 4 - check for duplicate blocks...
+        - setting up duplicate extent list...
+        - check for inodes claiming duplicate blocks...
+No modify flag set, skipping phase 5
+Phase 6 - check inode connectivity...
+        - traversing filesystem ...
+        - traversal finished ...
+        - moving disconnected inodes to lost+found ...
+Phase 7 - verify link counts...
+No modify flag set, skipping filesystem flush and exiting.
+Scrubbing repaired file system
+Reading from repaired file system
+
+
+Corrupting rtcsum inode mode
+
+Allowing write of corrupted data with good CRC
+core.mode = 0
+Checking corrupted file system
+Repairing corrupted file system
+Checking repaired file system
+Phase 1 - find and verify superblock...
+Phase 2 - using <TYPEOF> log
+        - zero log...
+        - scan filesystem freespace and inode maps...
+        - found root inode chunk
+Phase 3 - for each AG...
+        - scan (but don't clear) agi unlinked lists...
+        - process known inodes and perform inode discovery...
+        - process newly discovered inodes...
+Phase 4 - check for duplicate blocks...
+        - setting up duplicate extent list...
+        - check for inodes claiming duplicate blocks...
+No modify flag set, skipping phase 5
+Phase 6 - check inode connectivity...
+        - traversing filesystem ...
+        - traversal finished ...
+        - moving disconnected inodes to lost+found ...
+Phase 7 - verify link counts...
+No modify flag set, skipping filesystem flush and exiting.
+Scrubbing repaired file system
+Reading from repaired file system
+
+
+Corrupting rtcsum inode nextents
+
+Allowing write of corrupted data with good CRC
+core.nextents = 2
+Checking corrupted file system
+Repairing corrupted file system
+Checking repaired file system
+Phase 1 - find and verify superblock...
+Phase 2 - using <TYPEOF> log
+        - zero log...
+        - scan filesystem freespace and inode maps...
+        - found root inode chunk
+Phase 3 - for each AG...
+        - scan (but don't clear) agi unlinked lists...
+        - process known inodes and perform inode discovery...
+        - process newly discovered inodes...
+Phase 4 - check for duplicate blocks...
+        - setting up duplicate extent list...
+        - check for inodes claiming duplicate blocks...
+No modify flag set, skipping phase 5
+Phase 6 - check inode connectivity...
+        - traversing filesystem ...
+        - traversal finished ...
+        - moving disconnected inodes to lost+found ...
+Phase 7 - verify link counts...
+No modify flag set, skipping filesystem flush and exiting.
+Scrubbing repaired file system
+Reading from repaired file system
-- 
2.53.0


  parent reply	other threads:[~2026-09-24 10:09 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 10:07 xfstests support for RT data checksums Christoph Hellwig
2026-09-24 10:07 ` [PATCH 01/13] add a "datacsum" group Christoph Hellwig
2026-09-29  1:31   ` Darrick J. Wong
2026-10-05 13:17     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 02/13] common: add a SCRATCH_MKFS_OPTIONS variable Christoph Hellwig
2026-09-29  1:32   ` Darrick J. Wong
2026-10-05 13:18     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 03/13] xfs: add a XFS_VERIFY_FILE_DATA variable Christoph Hellwig
2026-09-29  1:34   ` Darrick J. Wong
2026-09-24 10:07 ` [PATCH 04/13] xfs/206: filter out csum information from mkfs output Christoph Hellwig
2026-09-29  1:34   ` Darrick J. Wong
2026-09-24 10:07 ` [PATCH 05/13] xfs: add a _require_xfs_data_csum helper Christoph Hellwig
2026-09-29  1:38   ` Darrick J. Wong
2026-10-05 13:20     ` Christoph Hellwig
2026-10-05 14:48       ` Darrick J. Wong
2026-10-05 14:55         ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 06/13] xfs/2301: test lazy bounce buffering mode Christoph Hellwig
2026-09-29  1:42   ` Darrick J. Wong
2026-10-05 13:21     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 07/13] xfs/2302: add a basic data checksum test Christoph Hellwig
2026-09-29  1:48   ` Darrick J. Wong
2026-10-05 13:22     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 08/13] xfs/2303: test that data checksums detect data misplacement Christoph Hellwig
2026-09-29  1:54   ` Darrick J. Wong
2026-10-05 13:23     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 09/13] xfs/2304: version of generic/388 that run xfs_scrub -x for each iteration Christoph Hellwig
2026-09-29  1:56   ` Darrick J. Wong
2026-10-05 13:25     ` Christoph Hellwig
2026-10-05 14:51       ` Darrick J. Wong
2026-10-05 14:56         ` Christoph Hellwig
2026-10-05 15:20           ` Darrick J. Wong
2026-10-07 13:42             ` Christoph Hellwig
2026-10-07 15:19               ` Darrick J. Wong
2026-09-24 10:07 ` [PATCH 10/13] xfs/2305: version of generic/475 " Christoph Hellwig
2026-09-29  1:57   ` Darrick J. Wong
2026-10-05 13:25     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 11/13] xfs/2306: test mkfs input validation for RT data csum options Christoph Hellwig
2026-09-29  1:59   ` Darrick J. Wong
2026-10-05 13:26     ` Christoph Hellwig
2026-09-24 10:07 ` Christoph Hellwig [this message]
2026-09-29  2:05   ` [PATCH 12/13] xfs/2307: test checksum handling using corrupted checksums Darrick J. Wong
2026-10-05 13:27     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 13/13] xfs/2308: test rebuilding of csum files in xfs_repair Christoph Hellwig
2026-09-29  2:03   ` Darrick J. Wong
2026-10-05 13:27     ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260924100855.2734089-13-hch@lst.de \
    --to=hch@lst.de \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox