]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/atomicwrites: adjust a few more things
authorDarrick J. Wong <djwong@kernel.org>
Mon, 2 Jun 2025 19:22:13 +0000 (12:22 -0700)
committerZorro Lang <zlang@kernel.org>
Thu, 5 Jun 2025 13:48:26 +0000 (21:48 +0800)
Always export STATX_WRITE_ATOMIC so anyone can use it, make the "cp
reflink" logic work for any filesystem, not just xfs, and create a
separate helper to check that the necessary xfs_io support is present.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/atomicwrites
tests/generic/765

index fd3a9b711077ace1f448a4fc1afab79eba086e61..9ec1ca68b04b82588fce583e2765c389a4779ea8 100644 (file)
@@ -4,6 +4,8 @@
 #
 # Routines for testing atomic writes.
 
+export STATX_WRITE_ATOMIC=0x10000
+
 _get_atomic_write_unit_min()
 {
        $XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
@@ -26,8 +28,6 @@ _require_scratch_write_atomic()
 {
        _require_scratch
 
-       export STATX_WRITE_ATOMIC=0x10000
-
        awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
        awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
 
@@ -51,6 +51,14 @@ _require_scratch_write_atomic()
        fi
 }
 
+# Check for xfs_io commands required to run _test_atomic_file_writes
+_require_atomic_write_test_commands()
+{
+       _require_xfs_io_command "falloc"
+       _require_xfs_io_command "fpunch"
+       _require_xfs_io_command pwrite -A
+}
+
 _test_atomic_file_writes()
 {
     local bsize="$1"
@@ -64,11 +72,7 @@ _test_atomic_file_writes()
     test $bytes_written -eq $bsize || echo "atomic write len=$bsize failed"
 
     # Check that we can perform an atomic single-block cow write
-    if [ "$FSTYP" == "xfs" ]; then
-        testfile_cp=$SCRATCH_MNT/testfile_copy
-        if _xfs_has_feature $SCRATCH_MNT reflink; then
-            cp --reflink $testfile $testfile_cp
-        fi
+    if cp --reflink=always $testfile $testfile_cp 2>> $seqres.full; then
         bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile_cp | \
             grep wrote | awk -F'[/ ]' '{print $2}')
         test $bytes_written -eq $bsize || echo "atomic write on reflinked file failed"
index 09e9fa387235f4e4593f61358e7ba6c2f0f9bbe7..71604e5e1e14741885964912045f5ac91aea94b6 100755 (executable)
@@ -12,7 +12,7 @@ _begin_fstest auto quick rw atomicwrites
 . ./common/atomicwrites
 
 _require_scratch_write_atomic
-_require_xfs_io_command pwrite -A
+_require_atomic_write_test_commands
 
 get_supported_bsize()
 {