]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic/767: only test the hardware atomic write unit
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Jul 2025 20:09:17 +0000 (13:09 -0700)
committerZorro Lang <zlang@kernel.org>
Sat, 2 Aug 2025 14:15:17 +0000 (22:15 +0800)
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/atomicwrites
tests/generic/767

index 95d545a67cadda32c3f06a5e58eee6a2edf740dc..33526399d2e980fc7fb639afa8fa767fcffd4321 100644 (file)
@@ -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 | \
index 31d599eacfd63b2bafce51cbd99d5f74ad7c2378..161fef03825db4c22d545cc1282d1695c50b82dd 100755 (executable)
@@ -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