From: Darrick J. Wong Date: Tue, 29 Jul 2025 20:09:17 +0000 (-0700) Subject: generic/767: only test the hardware atomic write unit X-Git-Tag: v2025.08.04~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ca57558daefe374a04bfceee5780c5765382e041;p=xfstests-dev.git generic/767: only test the hardware atomic write unit This test sets up scsi_debug so that we can test the fs and block layer code for hardware-accelerated atomic writes (and not just a software fallback). However, the userspace ABI for detecting atomic write geometry has changed since the start of development (to include said software fallback) so we must add some extra code to find the real hardware capabilities, and base the write sizes based on that. This fixes a test failure with 32k blocksizes because the advertised atomic_write_unit_max is 128M and fallocate quickly runs out of space. While we're at it fix a stupid variable usage bug in the loop. Cc: fstests@vger.kernel.org # v2025.07.13 Fixes: fa8694c823d853 ("generic: various atomic write tests with hardware and scsi_debug") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Zorro Lang --- diff --git a/common/atomicwrites b/common/atomicwrites index 95d545a6..33526399 100644 --- a/common/atomicwrites +++ b/common/atomicwrites @@ -18,6 +18,12 @@ _get_atomic_write_unit_max() grep -w atomic_write_unit_max | grep -o '[0-9]\+' } +_get_atomic_write_unit_max_opt() +{ + $XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \ + grep -w atomic_write_unit_max_opt | grep -o '[0-9]\+' +} + _get_atomic_write_segments_max() { $XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \ diff --git a/tests/generic/767 b/tests/generic/767 index 31d599ea..161fef03 100755 --- a/tests/generic/767 +++ b/tests/generic/767 @@ -61,8 +61,18 @@ $XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $testfile >> $seqres.full sector_size=$(blockdev --getss $SCRATCH_DEV) min_awu=$(_get_atomic_write_unit_min $testfile) max_awu=$(_get_atomic_write_unit_max $testfile) +opt_awu=$(_get_atomic_write_unit_max_opt $testfile) -$XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile +echo "min:$min_awu max:$max_awu opt:$opt_awu" >> $seqres.full + +# We want to test hardware support, so use that if detected +if [ -n "$opt_awu" ] && [ "$opt_awu" != "0" ]; then + write_size="$opt_awu" +else + write_size="$max_awu" +fi + +$XFS_IO_PROG -f -c "falloc 0 $((write_size * 2))" -c fsync $testfile # try outside the advertised sizes echo "two EINVAL for unsupported sizes" @@ -73,8 +83,8 @@ _simple_atomic_write $max_i $max_i $testfile -d # try all of the advertised sizes echo "all should work" -for ((i = min_awu; i <= max_awu; i *= 2)); do - $XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile +for ((i = min_awu; i <= write_size; i *= 2)); do + $XFS_IO_PROG -f -c "falloc 0 $((write_size * 2))" -c fsync $testfile _test_atomic_file_writes $i $testfile done