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 07/13] xfs/2302: add a basic data checksum test
Date: Thu, 24 Sep 2026 12:07:48 +0200 [thread overview]
Message-ID: <20260924100855.2734089-8-hch@lst.de> (raw)
In-Reply-To: <20260924100855.2734089-1-hch@lst.de>
Setup a zoned loop device, mess up the data and make sure both buffered
and direct I/O catch it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
tests/xfs/2302 | 96 ++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/2302.out | 25 ++++++++++++
2 files changed, 121 insertions(+)
create mode 100755 tests/xfs/2302
create mode 100644 tests/xfs/2302.out
diff --git a/tests/xfs/2302 b/tests/xfs/2302
new file mode 100755
index 000000000000..d0ef9abc87b0
--- /dev/null
+++ b/tests/xfs/2302
@@ -0,0 +1,96 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Christoph Hellwig
+#
+# FS QA Test No. 2302
+#
+# Test that data checksums detect data corruption using all three bounce
+# buffering modes.
+#
+. ./common/preamble
+. ./common/filter
+. ./common/zoned
+
+_begin_fstest auto zone quick datacsum
+
+cleanup_devices()
+{
+ [ -n "$mnt" ] && _unmount $mnt 2>/dev/null
+ [ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
+ _destroy_zloop $zloop_dev
+ cd /
+ rm -rf $loopfile $zloopdir $mnt
+}
+
+_cleanup()
+{
+ cleanup_devices
+}
+
+_require_test
+_require_loop
+_require_zloop
+# hack to only run for block based file systems
+_require_block_device $SCRATCH_DEV
+
+loopfile="$TEST_DIR/loopfile"
+zloopdir="$TEST_DIR/zloop"
+mnt="$TEST_DIR/mnt"
+
+test_error_detection()
+{
+ local bounce_mode=$1
+
+ echo
+ echo
+ echo "Testing bounce mode: $bounce_mode"
+ echo
+
+ rm -rf $loopfile $zloopdir $mnt
+ mkdir -p $mnt
+ truncate -s 1g $loopfile
+
+ local loop_dev=$(_create_loop_device $loopfile)
+ local zloop_dev=$(_create_zloop $zloopdir 256 0)
+ local zloop_id=$(echo $zloop_dev | grep -oE '[0-9]+$')
+
+ _try_mkfs_dev $loop_dev -r rtdev=$zloop_dev,csum=crc32c \
+ >> $seqres.full 2>&1 || \
+ _notrun "cannot mkfs filesystem with data checksums"
+ _mount $loop_dev -o rtdev=$zloop_dev $mnt
+
+ dd if=/dev/urandom of=$mnt/file bs=1M count=200 conv=fsync >/dev/null 2>&1
+
+ local rg=`xfs_bmap -v $mnt/file | head -n 3 | _filter_bmap_gno`
+ local zloop_filename=$(printf "seq-%06u\n" $rg)
+ local backing_file="$zloopdir/$zloop_id/$zloop_filename"
+
+ _unmount $mnt 2>/dev/null
+
+ # intentionally corrupt the data on the backing device
+ xfs_io $backing_file -d -c 'pwrite 0 16384' >> $seqres.full 2>&1
+
+ # should return an error on buffered read
+ _mount $loop_dev -o rtdev=$zloop_dev $mnt
+ _set_fs_sysfs_attr $loop_dev csum/read_bounce $bounce_mode
+ echo "Reading file using cat - should fail"
+ cat $mnt/file > /dev/null | _filter_test_dir
+
+ sleep 1
+ _unmount $mnt 2>/dev/null
+
+ # same with direct I/O
+ _mount $loop_dev -o rtdev=$zloop_dev $mnt
+ _set_fs_sysfs_attr $loop_dev csum/read_bounce $bounce_mode
+ echo "Reading file using O_DIRECT - should fail"
+ xfs_io -d $mnt/file -c 'pread 0 200M' | _filter_test_dir
+
+ sleep 1
+ cleanup_devices
+}
+
+test_error_detection "never"
+test_error_detection "always"
+test_error_detection "lazy"
+
+_exit 0
diff --git a/tests/xfs/2302.out b/tests/xfs/2302.out
new file mode 100644
index 000000000000..5e2108b5cec0
--- /dev/null
+++ b/tests/xfs/2302.out
@@ -0,0 +1,25 @@
+QA output created by 2302
+
+
+Testing bounce mode: never
+
+Reading file using cat - should fail
+cat: /mnt/test/mnt/file: Input/output error
+Reading file using O_DIRECT - should fail
+pread: Input/output error
+
+
+Testing bounce mode: always
+
+Reading file using cat - should fail
+cat: /mnt/test/mnt/file: Input/output error
+Reading file using O_DIRECT - should fail
+pread: Input/output error
+
+
+Testing bounce mode: lazy
+
+Reading file using cat - should fail
+cat: /mnt/test/mnt/file: Input/output error
+Reading file using O_DIRECT - should fail
+pread: Input/output error
--
2.53.0
next prev 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 ` Christoph Hellwig [this message]
2026-09-29 1:48 ` [PATCH 07/13] xfs/2302: add a basic data checksum test 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 ` [PATCH 12/13] xfs/2307: test checksum handling using corrupted checksums Christoph Hellwig
2026-09-29 2:05 ` 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-8-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.