All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Zorro Lang <zlang@kernel.org>,
	fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 08/13] xfs/2303: test that data checksums detect data misplacement
Date: Mon, 28 Sep 2026 18:54:39 -0700	[thread overview]
Message-ID: <20260929015439.GK2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260924100855.2734089-9-hch@lst.de>

On Thu, Sep 24, 2026 at 12:07:49PM +0200, Christoph Hellwig wrote:
> Test that data checksums detect data corruption due to misplacement
> by changing the backing files for two zones using the zloop driver.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/xfs/2303     | 88 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/2303.out |  5 +++
>  2 files changed, 93 insertions(+)
>  create mode 100755 tests/xfs/2303
>  create mode 100644 tests/xfs/2303.out
> 
> diff --git a/tests/xfs/2303 b/tests/xfs/2303
> new file mode 100755
> index 000000000000..7f53fdf94bff
> --- /dev/null
> +++ b/tests/xfs/2303
> @@ -0,0 +1,88 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Christoph Hellwig
> +#
> +# FS QA Test No. 2303
> +#
> +# Test that data checksums detect data corruption due to misplacement
> +# by changing the backing files for two zones using the zloop driver.
> +#
> +. ./common/preamble
> +. ./common/filter
> +. ./common/renameat2
> +. ./common/zoned
> +
> +_begin_fstest auto zone quick datacsum
> +
> +_cleanup()
> +{
> +	[ -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
> +}
> +
> +_require_test
> +_require_renameat2 "exchange"
> +_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"
> +
> +rm -rf $loopfile $zloopdir $mnt
> +mkdir -p $mnt
> +truncate -s 1g $loopfile
> +
> +loop_dev=$(_create_loop_device $loopfile)
> +zloop_dev=$(_create_zloop $zloopdir 256 0)
> +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/file1 bs=4k count=1 conv=fsync >/dev/null 2>&1
> +dd if=/dev/zero of=$mnt/file2 bs=4k count=1 conv=fsync >/dev/null 2>&1
> +
> +xfs_bmap -v $mnt/file1 >> $seqres.full 2>&1
> +xfs_bmap -v $mnt/file2 >> $seqres.full 2>&1
> +
> +rg1=`xfs_bmap -v $mnt/file1 | head -n 3 | _filter_bmap_gno`
> +rg2=`xfs_bmap -v $mnt/file2 | head -n 3 | _filter_bmap_gno`
> +if [ "$rg1" == "$rg2" ]; then
> +	_fail "both files placed in same RG: $rg1 $rg2"
> +fi
> +
> +zloop_filename1=$(printf "seq-%06u\n" $rg1)
> +backing_file1="$zloopdir/$zloop_id/$zloop_filename1"
> +zloop_filename2=$(printf "seq-%06u\n" $rg2)
> +backing_file2="$zloopdir/$zloop_id/$zloop_filename2"
> +
> +_unmount $mnt 2>/dev/null
> +_destroy_zloop $zloop_dev
> +
> +# intentionally corrupt data by swapping the two zone files
> +ls -i $backing_file1 $backing_file2 >> $seqres.full
> +echo "swapping file $backing_file1 and $backing_file2" >> $seqres.full
> +$here/src/renameat2 -x $backing_file1 $backing_file2
> +ls -i $backing_file1 $backing_file2 >> $seqres.full

Heh, this is an amusing way to induce a data checksum verification
failure -- switching the zone backing files. :)  Given that one of the
previous tests directly writes to the rt dev I think this one is less
important, but I guess that's one way to simulate an evil-maid device.

(Same nitpicks as the previous test)

--D

> +
> +zloop_dev=$(_create_zloop $zloopdir 256 0)
> +zloop_id=$(echo $zloop_dev | grep -oE '[0-9]+$')
> +_mount $loop_dev -o rtdev=$zloop_dev $mnt
> +
> +# should return an error on buffered read
> +echo "Reading file1 using cat - should fail"
> +cat $mnt/file1 > /dev/null | _filter_test_dir
> +
> +# same with direct I/O
> +echo "Reading file2 using O_DIRECT - should fail"
> +xfs_io -d $mnt/file2 -c 'pread 0 200M' | _filter_test_dir
> +
> +_exit 0
> diff --git a/tests/xfs/2303.out b/tests/xfs/2303.out
> new file mode 100644
> index 000000000000..fca2c4830e3c
> --- /dev/null
> +++ b/tests/xfs/2303.out
> @@ -0,0 +1,5 @@
> +QA output created by 2303
> +Reading file1 using cat - should fail
> +cat: /mnt/test/mnt/file1: Input/output error
> +Reading file2 using O_DIRECT - should fail
> +pread: Input/output error
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-09-29  1:54 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 [this message]
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=20260929015439.GK2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@lst.de \
    --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.