add tests for file system on devices using protection information v2
Hi all,
this series adds support to exercise I/O on file systems using protection information in the device, including that corruption is properly reported.
The second test requires a patch to inject corruption into scsi_debug that was posted to the linux-scsi list.
Changes since v1:
- fix various requirements
- use _exit
- cleanup up the scsi_debug options building
- add a new PI group
- mark one of the new tests dangerous as it can crash Linux 7.2 and earlier
PATCH 1/5 common/scsi_debug: don't slow down I/O
scsi_debug by defaults delays I/O and doesn't support multi-page I/O. Flipping these defaults speed up each test using scsi_debug by more than an order of magnitute on my test systems.
--- common/scsi_debug | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
common/scsi_debug +13 -3
@@ -59,9 +59,19 @@ _get_scsi_debug_dev() let physical=physical/2 let phys_exp=phys_exp+1 done - opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size $@" - echo "scsi_debug options $opts" >> $seqres.full - modprobe scsi_debug $opts + + local opts=( + "sector_size=$logical" + "physblk_exp=$phys_exp" + "lowest_aligned=$unaligned" + "dev_size_mb=$size" + "delay=0" + "clustering=1" + ) + opts+=("$@") + + echo "scsi_debug options ${opts[*]}" >> $seqres.full + modprobe scsi_debug "${opts[@]}" [ $? -eq 0 ] || _fail "scsi_debug modprobe failed" $UDEV_SETTLE_PROG device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
Signature · 1 line
2.53.0
Re: [PATCH 1/5] common/scsi_debug: don't slow down I/O
Quoted 1 line · Christoph Hellwig
scsi_debugby defaults delays I/O
Maybe we can just make delay=0 default for that driver. Or use ndelay > 0.
Quoted 5 lines
and doesn't support multi-page I/O.
Flipping these defaults speed up each test usingscsi_debugby more than an order of magnitute on my test systems.Signed-off-by Christoph Hellwig <[email protected]>
FWIW:
Quoted 31 lines
--- common/scsi_debug | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)common/scsi_debug +13
-3@@ -59,9 +59,19 @@ _get_scsi_debug_dev() let physical=physical/2 let phys_exp=phys_exp+1 done - opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size $@" - echo "scsi_debug options $opts" >> $seqres.full - modprobe scsi_debug $opts + + local opts=( + "sector_size=$logical" + "physblk_exp=$phys_exp" + "lowest_aligned=$unaligned" + "dev_size_mb=$size" + "delay=0" + "clustering=1" + ) + opts+=("$@") + + echo "scsi_debug options ${opts[*]}" >> $seqres.full + modprobe scsi_debug "${opts[@]}" [ $? -eq 0 ] || _fail "scsi_debug modprobe failed" $UDEV_SETTLE_PROG device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
Re: [PATCH 1/5] common/scsi_debug: don't slow down I/O
Quoted 4 lines · John Garry
Quoted 1 line · Christoph Hellwig
scsi_debugby defaults delays I/OMaybe we can just make delay=0 default for that driver. Or use ndelay > 0.
I'm in favor of changing the default delay to zero. It's what most users need and it's easy to forget to specify delay=0 when loading scsi_debug.
Thanks,
Bart.
Darrick J. Wong
Reviewed-byRe: [PATCH 1/5] common/scsi_debug: don't slow down I/O
Quoted 8 lines · Bart Van Assche
Quoted 4 lines · John Garry
Quoted 1 line · Christoph Hellwig
scsi_debugby defaults delays I/OMaybe we can just make delay=0 default for that driver. Or use ndelay > 0.
I'm in favor of changing the default delay to zero. It's what most users need and it's easy to forget to specify delay=0 when loading
scsi_debug.
I didn't even *know* that you had to do that!
I agree with these changes.
--D
Quoted 4 lines
Thanks,
Bart.
Re: [PATCH 1/5] common/scsi_debug: don't slow down I/O
In reply to Bart Van AsscheQuoted 8 lines · Bart Van Assche
Quoted 4 lines · John Garry
Quoted 1 line · Christoph Hellwig
scsi_debugby defaults delays I/OMaybe we can just make delay=0 default for that driver. Or use ndelay > 0.
I'm in favor of changing the default delay to zero. It's what most users need and it's easy to forget to specify delay=0 when loading
scsi_debug.
I won't object such a patch. But we'll still want to force this in xfstests to not rely on such a change.
PATCH 2/5 common: add a _sysfs_block_integrity_path helper
In reply to Christoph HellwigAdd a helper function to find the sysfs integrity directory for a given block device.
--- common/rc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
common/rc +25 -0
@@ -5257,6 +5257,31 @@ _sysfs_queue_path() fi } +# Get the sysfs block device integrity/ path for a block device, handling +# partitions correctly. +_sysfs_block_integrity_path() +{ + local dev parent + dev=$(_short_dev "$1") + + # For partitions, integrity details are in the parent device's sysfs dir + if [ -e "/sys/class/block/$dev/partition" ]; then + parent=$(basename "$(readlink -f /sys/class/block/$dev/..)") + else + parent="$dev" + fi + + local integrity_path="/sys/block/$parent/integrity" + + # Verify the path exists before returning + if [ -e "$integrity_path" ]; then + echo "$integrity_path" + return 0 + fi + + return 1 +} + # Get the minimum block size of a file. Usually this is the # minimum fs block size, but some filesystems (ocfs2) do block # mappings in larger units.
Signature · 1 line
2.53.0
Re: [PATCH 2/5] common: add a _sysfs_block_integrity_path helper
Quoted 19 lines · Christoph Hellwig
Add a helper function to find the sysfs integrity directory for a given block device.
Signed-off-by Christoph Hellwig <[email protected]>--- common/rc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)common/rc +3
-0@@ -5257,6 +5257,31 @@ _sysfs_queue_path() fi } +# Get the sysfs block device integrity/ path for a block device, handling +# partitions correctly. +_sysfs_block_integrity_path()
common/rc _sysfs_queue_path() · line 5272
Quoted 10 lines
common/rc +10
-0+{ + local dev parent + dev=$(_short_dev "$1") + + # For partitions, integrity details are in the parent device's sysfs dir + if [ -e "/sys/class/block/$dev/partition" ]; then + parent=$(basename "$(readlink -f /sys/class/block/$dev/..)") + else + parent="$dev" + fi
I wonder if this part should get pulled out into a _sysfs_block_path helper, since the code is already in _sysfs_queue_path?
--D
Quoted 19 lines
common/rc +12
-0+ + local integrity_path="/sys/block/$parent/integrity" + + # Verify the path exists before returning + if [ -e "$integrity_path" ]; then + echo "$integrity_path" + return 0 + fi + + return 1 +} + # Get the minimum block size of a file. Usually this is the # minimum fs block size, but some filesystems (ocfs2) do block # mappings in larger units.Signature · 1 line
2.53.0
Re: [PATCH 2/5] common: add a _sysfs_block_integrity_path helper
Quoted 17 lines · Darrick J. Wong
Quoted 16 lines · Christoph Hellwig
Add a helper function to find the sysfs integrity directory for a given block device.
Signed-off-by Christoph Hellwig <[email protected]>--- common/rc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)common/rc +0
-0@@ -5257,6 +5257,31 @@ _sysfs_queue_path() fi }
Quoted 16 lines
common/rc _sysfs_queue_path() · line 5272
Quoted 13 lines
common/rc +13
-0+# Get the sysfs block device integrity/ path for a block device, handling +# partitions correctly. +_sysfs_block_integrity_path() +{ + local dev parent + dev=$(_short_dev "$1") + + # For partitions, integrity details are in the parent device's sysfs dir + if [ -e "/sys/class/block/$dev/partition" ]; then + parent=$(basename "$(readlink -f /sys/class/block/$dev/..)") + else + parent="$dev" + fiI wonder if this part should get pulled out into a
_sysfs_block_pathhelper, since the code is already in_sysfs_queue_path?
I guess. It's not much code, but it is identical.
PATCH 3/5 add a "pi" group
In reply to Christoph HellwigAdd a group for tests exercising T10 protection information.
--- doc/group-names.txt | 1 + 1 file changed, 1 insertion(+)
doc/group-names.txt +1 -0
@@ -137,6 +137,7 @@ tape dump and restore with a tape tempfsid temporary fsid thin thin provisioning trim FITRIM ioctl +pi Protection Information udf UDF functionality tests union tests from the unionmount test suite unlink O_TMPFILE unlinked files
Signature · 1 line
2.53.0
Re: [PATCH 3/5] add a "pi" group
Quoted 3 lines · Christoph Hellwig
Add a group for tests exercising T10 protection information.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good,
--D
Quoted 20 lines
--- doc/group-names.txt | 1 + 1 file changed, 1 insertion(+)doc/group-names.txt +1
-0@@ -137,6 +137,7 @@ tape dump and restore with a tape tempfsid temporary fsid thin thin provisioning trim FITRIM ioctl +pi Protection Information udf UDF functionality tests union tests from the unionmount test suite unlink O_TMPFILE unlinked filesSignature · 1 line
2.53.0
PATCH 4/5 generic: test I/O on devices with T10 protection information
In reply to Christoph HellwigAdd a test that runs fsx in buffered and direct I/O mode on T10 PI type 1, 2, 3 with and without strip/insert using scsi_debug.
--- tests/generic/2301 | 91 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/2301.out | 73 +++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100755 tests/generic/2301 create mode 100644 tests/generic/2301.out
tests/generic/2301 new file +91 -0
@@ -0,0 +1,91 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Christoph Hellwig +# +# FS QA Test No. 2301 +# +# Basix FSX sanity check when using T10 protection information +# +. ./common/preamble +_begin_fstest auto rw pi dangerous + +_cleanup() +{ + cd / + rm -r -f $tmp.* + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +. ./common/scsi_debug + +_require_debugfs +_require_scsi_debug +# If TEST_DEV is block device, make sure current fs is a localfs which can be +# written on scsi_debug device +_require_test +_require_block_device $TEST_DEV +_require_odirect + +size=$(_small_fs_size_mb 256) + +# like run_fsx(), but using a custom path +fsx_run() +{ + _run_fsx_on_file $SCSI_DEBUG_MNT/junk $@ || _exit 1 +} + +test_dif() +{ + local pi_type=$1 + local pi_enable="$2" + + scsi_debug_pi_opts="write_same_length=0 dif=${pi_type} dix=1" + SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size $scsi_debug_pi_opts` + + SCSI_DEBUG_MNT="$TEST_DIR/scsi_debug_$seq" + rm -rf $SCSI_DEBUG_MNT + mkdir $SCSI_DEBUG_MNT + + _mkfs_dev $SCSI_DEBUG_DEV || \ + _fail "Can't make $FSTYP on DIF-enabled scsi_debug device" + run_check _mount $SCSI_DEBUG_DEV $SCSI_DEBUG_MNT + bsize=$($here/src/min_dio_alignment $SCSI_DEBUG_MNT $SCSI_DEBUG_DEV) + + local integrity_path="$(_sysfs_block_integrity_path $SCSI_DEBUG_DEV)" + echo $pi_enable > $integrity_path/read_verify + echo $pi_enable > $integrity_path/write_generate + + # fsx load similar to generic/091 + echo "Testing direct I/O for DIF type $pi_type (enabled: $pi_enable)" + local dio_opts="-r PSIZE -t BSIZE -w BSIZE" + fsx_run -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W + + # fsx load similar to generic/091 but using buffered I/O + echo "Testing buffered I/O for DIF type $pi_type (enabled: $pi_enable)" + fsx_run -N 10000 -l 500000 + fsx_run -N 10000 -o 8192 -l 500000 + fsx_run -N 10000 -o 32768 -l 500000 + fsx_run -N 10000 -o 128000 -l 500000 + + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +# Test with PI fully enabled +test_dif 1 1 +test_dif 2 1 +test_dif 3 1 + +# Test with strip / insert in the HBA +test_dif 1 0 +test_dif 2 0 +test_dif 3 0 + +# success, all done +_exit 0
tests/generic/2301.out new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 4/5] generic: test I/O on devices with T10 protection information
Quoted 17 lines · Christoph Hellwig
Add a test that runs fsx in buffered and direct I/O mode on T10 PI type 1, 2, 3 with and without strip/insert using
scsi_debug.Signed-off-by Christoph Hellwig <[email protected]>--- tests/generic/2301 | 91 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/2301.out | 73 +++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100755 tests/generic/2301 create mode 100644 tests/generic/2301.outtests/generic/2301 new file +0
-0
tests/generic/2301 line 10
Quoted 10 lines
tests/generic/2301 new file +10
-0@@ -0,0 +1,91 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Christoph Hellwig +# +# FS QA Test No. 2301 +# +# Basix FSX sanity check when using T10 protection information +# +. ./common/preamble +_begin_fstest auto rw pi dangerous
Why dangerous? Can this crash the system?
Quoted 31 lines
tests/generic/2301 new file +31
-0+ +_cleanup() +{ + cd / + rm -r -f $tmp.* + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +. ./common/scsi_debug + +_require_debugfs +_require_scsi_debug +# If TEST_DEV is block device, make sure current fs is a localfs which can be +# written on scsi_debug device +_require_test +_require_block_device $TEST_DEV +_require_odirect + +size=$(_small_fs_size_mb 256) + +# like run_fsx(), but using a custom path +fsx_run() +{ + _run_fsx_on_file $SCSI_DEBUG_MNT/junk $@ || _exit 1 +} + +test_dif() +{ + local pi_type=$1 + local pi_enable="$2"
tests/generic/2301 line 51
Quoted 10 lines
tests/generic/2301 new file +10
-0+ + scsi_debug_pi_opts="write_same_length=0 dif=${pi_type} dix=1" + SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size $scsi_debug_pi_opts` + + SCSI_DEBUG_MNT="$TEST_DIR/scsi_debug_$seq" + rm -rf $SCSI_DEBUG_MNT + mkdir $SCSI_DEBUG_MNT + + _mkfs_dev $SCSI_DEBUG_DEV || \ + _fail "Can't make $FSTYP on DIF-enabled scsi_debug device"
I wonder, wouldn't it help to broaden feature testing coverage if we could inject the scratch device's mkfs/mount options here? With just a bare _mkfs_dev you only test the mkfs defaults. For example, you won't be testing xfs with metadir and t10 until mkfs.xfs turns that on by default.
That said, the big problem with that is that there's only one scsi-debug device and multi-device scratch fs options won't work with that. I'm not ride-or-die for this, but I thought it was worth mentioning.
--D
Quoted 123 lines
tests/generic/2301 new file +40
-0+ run_check _mount $SCSI_DEBUG_DEV $SCSI_DEBUG_MNT + bsize=$($here/src/min_dio_alignment $SCSI_DEBUG_MNT $SCSI_DEBUG_DEV) + + local integrity_path="$(_sysfs_block_integrity_path $SCSI_DEBUG_DEV)" + echo $pi_enable > $integrity_path/read_verify + echo $pi_enable > $integrity_path/write_generate + + # fsx load similar to generic/091 + echo "Testing direct I/O for DIF type $pi_type (enabled: $pi_enable)" + local dio_opts="-r PSIZE -t BSIZE -w BSIZE" + fsx_run -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W + fsx_run -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W + + # fsx load similar to generic/091 but using buffered I/O + echo "Testing buffered I/O for DIF type $pi_type (enabled: $pi_enable)" + fsx_run -N 10000 -l 500000 + fsx_run -N 10000 -o 8192 -l 500000 + fsx_run -N 10000 -o 32768 -l 500000 + fsx_run -N 10000 -o 128000 -l 500000 + + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +# Test with PI fully enabled +test_dif 1 1 +test_dif 2 1 +test_dif 3 1 + +# Test with strip / insert in the HBA +test_dif 1 0 +test_dif 2 0 +test_dif 3 0 + +# success, all done +_exit 0tests/generic/2301.out new file +73
-0@@ -0,0 +1,73 @@ +QA output created by 2301 +Testing direct I/O for DIF type 1 (enabled: 1) +fsx -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W +Testing buffered I/O for DIF type 1 (enabled: 1) +fsx -N 10000 -l 500000 +fsx -N 10000 -o 8192 -l 500000 +fsx -N 10000 -o 32768 -l 500000 +fsx -N 10000 -o 128000 -l 500000 +Testing direct I/O for DIF type 2 (enabled: 1) +fsx -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W +Testing buffered I/O for DIF type 2 (enabled: 1) +fsx -N 10000 -l 500000 +fsx -N 10000 -o 8192 -l 500000 +fsx -N 10000 -o 32768 -l 500000 +fsx -N 10000 -o 128000 -l 500000 +Testing direct I/O for DIF type 3 (enabled: 1) +fsx -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W +Testing buffered I/O for DIF type 3 (enabled: 1) +fsx -N 10000 -l 500000 +fsx -N 10000 -o 8192 -l 500000 +fsx -N 10000 -o 32768 -l 500000 +fsx -N 10000 -o 128000 -l 500000 +Testing direct I/O for DIF type 1 (enabled: 0) +fsx -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W +Testing buffered I/O for DIF type 1 (enabled: 0) +fsx -N 10000 -l 500000 +fsx -N 10000 -o 8192 -l 500000 +fsx -N 10000 -o 32768 -l 500000 +fsx -N 10000 -o 128000 -l 500000 +Testing direct I/O for DIF type 2 (enabled: 0) +fsx -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W +Testing buffered I/O for DIF type 2 (enabled: 0) +fsx -N 10000 -l 500000 +fsx -N 10000 -o 8192 -l 500000 +fsx -N 10000 -o 32768 -l 500000 +fsx -N 10000 -o 128000 -l 500000 +Testing direct I/O for DIF type 3 (enabled: 0) +fsx -N 10000 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 8192 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 32768 -l 500000 -r BSIZE -w BSIZE -Z -R -W +fsx -N 10000 -o 128000 -l 500000 -r BSIZE -w BSIZE -Z -W +Testing buffered I/O for DIF type 3 (enabled: 0) +fsx -N 10000 -l 500000 +fsx -N 10000 -o 8192 -l 500000 +fsx -N 10000 -o 32768 -l 500000 +fsx -N 10000 -o 128000 -l 500000Signature · 1 line
2.53.0
Re: [PATCH 4/5] generic: test I/O on devices with T10 protection information
Quoted 5 lines · Darrick J. Wong
Quoted 5 lines
tests/generic/2301 new file +4
-0@@ -0,0 +1,91 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Christoph Hellwig +#
Quoted 8 lines
tests/generic/2301 line 10
Quoted 6 lines
tests/generic/2301 new file +6
-0+# FS QA Test No. 2301 +# +# Basix FSX sanity check when using T10 protection information +# +. ./common/preamble +_begin_fstest auto rw pi dangerousWhy dangerous? Can this crash the system?
Yes, the strip/insert case (which needs to be enabled through sysfs crashes all release kernels up to and including 7.2.
PATCH 5/5 generic: test corruption detection using T10 protection information
In reply to Christoph HellwigAdd a test that simulates bit flips in data and misdirected writes and checks that file systems detect it when run on devices using protection information.
This requires the new scsi_debug corruption injection.
--- tests/generic/2302 | 128 +++++++++++++++++++++++++++++++++++++++++ tests/generic/2302.out | 21 +++++++ 2 files changed, 149 insertions(+) create mode 100755 tests/generic/2302 create mode 100644 tests/generic/2302.out
tests/generic/2302 new file +128 -0
@@ -0,0 +1,128 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Christoph Hellwig +# +# FS QA Test No. 2302 +# +# Test that T10 DIF detects bitflips and misplaced writes. +# +. ./common/preamble +_begin_fstest auto rw pi + +_cleanup() +{ + cd / + rm -r -f $tmp.* + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +. ./common/scsi_debug +. ./common/filter + +_require_debugfs +_require_scsi_debug +# If TEST_DEV is block device, make sure current fs is a localfs which can be +# written on scsi_debug device +_require_test +_require_block_device $TEST_DEV +_require_xfs_io_command fiemap +_require_odirect + +# FIEMAP on Btrfs returns logical addresses within the filesystem's address +# space, not physical device offsets. Writing to these offsets on $SCRATCH_DEV +# would corrupt the filesystem in multi-device setups. +_exclude_fs btrfs + +size=$(_small_fs_size_mb 256) + +test_dif() +{ + local pi_type=$1 + local last=$2 + local bit_errors=$3 + local reftag_adjust=$4 + + echo -n "Testing DIF type $pi_type " + if [ "$bit_errors" -gt "0" ]; then + echo -n "bit errors ($bit_errors) in " + fi + if [ "$reftag_adjust" -ne "0" ]; then + echo -n "reftag adjustment by $reftag_adjust in " + fi + if [ "$last" -eq 1 ]; then + echo "last sector" + else + echo "first sector" + fi + + scsi_debug_pi_opts="write_same_length=0 dif=${pi_type} dix=1" + SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size $scsi_debug_pi_opts` + + SCSI_DEBUG_MNT="$TEST_DIR/scsi_debug_$seq" + rm -rf $SCSI_DEBUG_MNT + mkdir $SCSI_DEBUG_MNT + + _mkfs_dev $SCSI_DEBUG_DEV || \ + _fail "Can't make $FSTYP on DIF-enabled scsi_debug device" + run_check _mount $SCSI_DEBUG_DEV $SCSI_DEBUG_MNT + + local blksz=$(_get_block_size $SCSI_DEBUG_MNT) + local testfile="$SCSI_DEBUG_MNT/test" + + $XFS_IO_PROG -d -f \ + -c "pwrite -S 0x66 0 $((128 * blksz))" \ + -c fsync \ + $testfile >> $seqres.full 2>&1 + + local phys_blk=$(_get_file_extent_sector $testfile 0) + if [ -z "$phys_blk" ]; then + _fail "$test_name: failed to get physical block offset via fiemap" + fi + + local dev=$(_short_dev $SCSI_DEBUG_DEV) + local debugfs_dir=$(ls /sys/block/$dev/device/scsi_device/) + local debugfs_file="/sys/kernel/debug/scsi_debug/$debugfs_dir/corrupt" + + if [ ! -f "$debugfs_file" ]; then + _notrun "scsi_debug corruption injection not supported" + fi + + if [ "$last" -eq 1 ]; then + echo "adding to $phys_blk" >> $seqres.full + phys_blk=$((phys_blk + 127)) + fi + + echo "lba=$phys_blk,num=1,bit_errors=$bit_errors,reftag_adjust=$reftag_adjust" \ + > $debugfs_file + + $XFS_IO_PROG -d -f \ + -c "pread 0 $((128 * blksz))" \ + $testfile + + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +# test data corruption in first block +test_dif 1 0 2 0 +test_dif 2 0 2 0 +test_dif 3 0 2 0 + +# test data corruption in last block +test_dif 1 1 2 0 +test_dif 2 1 2 0 +test_dif 3 1 2 0 + + +# Note: Type 3 doesn't have a refrag, so don't test it + +# reftag mismatch in first block +test_dif 1 0 0 8 +test_dif 2 0 0 8 + +# reftag mismatch in last block +test_dif 1 1 0 8 +test_dif 2 1 0 8 + +_exit 0
tests/generic/2302.out new file +21 -0
@@ -0,0 +1,21 @@ +QA output created by 2302 +Testing DIF type 1 bit errors (2) in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 bit errors (2) in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 3 bit errors (2) in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 1 bit errors (2) in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 bit errors (2) in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 3 bit errors (2) in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 1 reftag adjustment by 8 in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 reftag adjustment by 8 in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 1 reftag adjustment by 8 in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 reftag adjustment by 8 in last sector +pread: Invalid or incomplete multibyte or wide character
Signature · 1 line
2.53.0
Re: [PATCH 5/5] generic: test corruption detection using T10 protection information
Quoted 7 lines · Christoph Hellwig
Add a test that simulates bit flips in data and misdirected writes and checks that file systems detect it when run on devices using protection information.
This requires the new
scsi_debugcorruption injection.Signed-off-by Christoph Hellwig <[email protected]>
Looks good to me (this patch and the previous one), so
--D
Quoted 172 lines
--- tests/generic/2302 | 128 +++++++++++++++++++++++++++++++++++++++++ tests/generic/2302.out | 21 +++++++ 2 files changed, 149 insertions(+) create mode 100755 tests/generic/2302 create mode 100644 tests/generic/2302.outtests/generic/2302 new file +128
-0@@ -0,0 +1,128 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Christoph Hellwig +# +# FS QA Test No. 2302 +# +# Test that T10 DIF detects bitflips and misplaced writes. +# +. ./common/preamble +_begin_fstest auto rw pi + +_cleanup() +{ + cd / + rm -r -f $tmp.* + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +. ./common/scsi_debug +. ./common/filter + +_require_debugfs +_require_scsi_debug +# If TEST_DEV is block device, make sure current fs is a localfs which can be +# written on scsi_debug device +_require_test +_require_block_device $TEST_DEV +_require_xfs_io_command fiemap +_require_odirect + +# FIEMAP on Btrfs returns logical addresses within the filesystem's address +# space, not physical device offsets. Writing to these offsets on $SCRATCH_DEV +# would corrupt the filesystem in multi-device setups. +_exclude_fs btrfs + +size=$(_small_fs_size_mb 256) + +test_dif() +{ + local pi_type=$1 + local last=$2 + local bit_errors=$3 + local reftag_adjust=$4 + + echo -n "Testing DIF type $pi_type " + if [ "$bit_errors" -gt "0" ]; then + echo -n "bit errors ($bit_errors) in " + fi + if [ "$reftag_adjust" -ne "0" ]; then + echo -n "reftag adjustment by $reftag_adjust in " + fi + if [ "$last" -eq 1 ]; then + echo "last sector" + else + echo "first sector" + fi + + scsi_debug_pi_opts="write_same_length=0 dif=${pi_type} dix=1" + SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size $scsi_debug_pi_opts` + + SCSI_DEBUG_MNT="$TEST_DIR/scsi_debug_$seq" + rm -rf $SCSI_DEBUG_MNT + mkdir $SCSI_DEBUG_MNT + + _mkfs_dev $SCSI_DEBUG_DEV || \ + _fail "Can't make $FSTYP on DIF-enabled scsi_debug device" + run_check _mount $SCSI_DEBUG_DEV $SCSI_DEBUG_MNT + + local blksz=$(_get_block_size $SCSI_DEBUG_MNT) + local testfile="$SCSI_DEBUG_MNT/test" + + $XFS_IO_PROG -d -f \ + -c "pwrite -S 0x66 0 $((128 * blksz))" \ + -c fsync \ + $testfile >> $seqres.full 2>&1 + + local phys_blk=$(_get_file_extent_sector $testfile 0) + if [ -z "$phys_blk" ]; then + _fail "$test_name: failed to get physical block offset via fiemap" + fi + + local dev=$(_short_dev $SCSI_DEBUG_DEV) + local debugfs_dir=$(ls /sys/block/$dev/device/scsi_device/) + local debugfs_file="/sys/kernel/debug/scsi_debug/$debugfs_dir/corrupt" + + if [ ! -f "$debugfs_file" ]; then + _notrun "scsi_debug corruption injection not supported" + fi + + if [ "$last" -eq 1 ]; then + echo "adding to $phys_blk" >> $seqres.full + phys_blk=$((phys_blk + 127)) + fi + + echo "lba=$phys_blk,num=1,bit_errors=$bit_errors,reftag_adjust=$reftag_adjust" \ + > $debugfs_file + + $XFS_IO_PROG -d -f \ + -c "pread 0 $((128 * blksz))" \ + $testfile + + [ -d "$SCSI_DEBUG_MNT" ] && _unmount $SCSI_DEBUG_MNT 2>/dev/null + _put_scsi_debug_dev +} + +# test data corruption in first block +test_dif 1 0 2 0 +test_dif 2 0 2 0 +test_dif 3 0 2 0 + +# test data corruption in last block +test_dif 1 1 2 0 +test_dif 2 1 2 0 +test_dif 3 1 2 0 + + +# Note: Type 3 doesn't have a refrag, so don't test it + +# reftag mismatch in first block +test_dif 1 0 0 8 +test_dif 2 0 0 8 + +# reftag mismatch in last block +test_dif 1 1 0 8 +test_dif 2 1 0 8 + +_exit 0tests/generic/2302.out new file +21
-0@@ -0,0 +1,21 @@ +QA output created by 2302 +Testing DIF type 1 bit errors (2) in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 bit errors (2) in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 3 bit errors (2) in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 1 bit errors (2) in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 bit errors (2) in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 3 bit errors (2) in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 1 reftag adjustment by 8 in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 reftag adjustment by 8 in first sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 1 reftag adjustment by 8 in last sector +pread: Invalid or incomplete multibyte or wide character +Testing DIF type 2 reftag adjustment by 8 in last sector +pread: Invalid or incomplete multibyte or wide characterSignature · 1 line
2.53.0