linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] atomic writes tests (part 1)
@ 2025-06-02 19:22 Catherine Hoang
  2025-06-02 19:22 ` [PATCH 1/5] generic/765: fix a few issues Catherine Hoang
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Catherine Hoang @ 2025-06-02 19:22 UTC (permalink / raw)
  To: linux-xfs, fstests; +Cc: djwong, john.g.garry, ritesh.list, ojaswin

Hi all,

These are the first 5 patches from the previous atomic writes test series.
https://lore.kernel.org/linux-xfs/20250520013400.36830-1-catherine.hoang@oracle.com/
I plan on addressing comments from patch 6 in a separate series since there
were requests to split that up into multiple patches.

No changes were made except for picking up a couple rvb tags.
This series is based on for-next at the time of sending.

Darrick J. Wong (5):
  generic/765: fix a few issues
  generic/765: adjust various things
  generic/765: move common atomic write code to a library file
  common/atomicwrites: adjust a few more things
  common/atomicwrites: fix _require_scratch_write_atomic

 common/atomicwrites | 117 ++++++++++++++++++++++++++++++++++++++++++++
 common/rc           |  49 +------------------
 doc/group-names.txt |   1 +
 tests/generic/765   |  84 ++++++++++++-------------------
 4 files changed, 149 insertions(+), 102 deletions(-)
 create mode 100644 common/atomicwrites

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5] generic/765: fix a few issues
  2025-06-02 19:22 [PATCH 0/5] atomic writes tests (part 1) Catherine Hoang
@ 2025-06-02 19:22 ` Catherine Hoang
  2025-06-04 13:58   ` John Garry
  2025-06-02 19:22 ` [PATCH 2/5] generic/765: adjust various things Catherine Hoang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Catherine Hoang @ 2025-06-02 19:22 UTC (permalink / raw)
  To: linux-xfs, fstests; +Cc: djwong, john.g.garry, ritesh.list, ojaswin

From: "Darrick J. Wong" <djwong@kernel.org>

Fix a few bugs in the single block atomic writes test, such as not requiring
directio, using the page size for the ext4 max bsize, and making sure we check
the max atomic write size.

Cc: ritesh.list@gmail.com
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
 common/rc         | 2 +-
 tests/generic/765 | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/rc b/common/rc
index d8ee8328..d34763ff 100644
--- a/common/rc
+++ b/common/rc
@@ -2989,7 +2989,7 @@ _require_xfs_io_command()
 		fi
 		if [ "$param" == "-A" ]; then
 			opts+=" -d"
-			pwrite_opts+="-D -V 1 -b 4k"
+			pwrite_opts+="-V 1 -b 4k"
 		fi
 		testio=`$XFS_IO_PROG -f $opts -c \
 		        "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`
diff --git a/tests/generic/765 b/tests/generic/765
index 9bab3b8a..8695a306 100755
--- a/tests/generic/765
+++ b/tests/generic/765
@@ -28,7 +28,7 @@ get_supported_bsize()
         ;;
     "ext4")
         min_bsize=1024
-        max_bsize=4096
+        max_bsize=$(_get_page_size)
         ;;
     *)
         _notrun "$FSTYP does not support atomic writes"
@@ -73,7 +73,7 @@ test_atomic_writes()
     # Check that atomic min/max = FS block size
     test $file_min_write -eq $bsize || \
         echo "atomic write min $file_min_write, should be fs block size $bsize"
-    test $file_min_write -eq $bsize || \
+    test $file_max_write -eq $bsize || \
         echo "atomic write max $file_max_write, should be fs block size $bsize"
     test $file_max_segments -eq 1 || \
         echo "atomic write max segments $file_max_segments, should be 1"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/5] generic/765: adjust various things
  2025-06-02 19:22 [PATCH 0/5] atomic writes tests (part 1) Catherine Hoang
  2025-06-02 19:22 ` [PATCH 1/5] generic/765: fix a few issues Catherine Hoang
@ 2025-06-02 19:22 ` Catherine Hoang
  2025-06-02 19:22 ` [PATCH 3/5] generic/765: move common atomic write code to a library file Catherine Hoang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Catherine Hoang @ 2025-06-02 19:22 UTC (permalink / raw)
  To: linux-xfs, fstests; +Cc: djwong, john.g.garry, ritesh.list, ojaswin

From: "Darrick J. Wong" <djwong@kernel.org>

Fix some bugs when detecting the atomic write geometry, record what
atomic write geometry we're testing each time through the loop, and
create a group for atomic writes tests.

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>
---
 common/rc           |  4 ++--
 doc/group-names.txt |  1 +
 tests/generic/765   | 25 ++++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/common/rc b/common/rc
index d34763ff..f7d38894 100644
--- a/common/rc
+++ b/common/rc
@@ -5452,13 +5452,13 @@ _get_atomic_write_unit_min()
 _get_atomic_write_unit_max()
 {
 	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
-        grep atomic_write_unit_max | grep -o '[0-9]\+'
+        grep -w atomic_write_unit_max | grep -o '[0-9]\+'
 }
 
 _get_atomic_write_segments_max()
 {
 	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
-        grep atomic_write_segments_max | grep -o '[0-9]\+'
+        grep -w atomic_write_segments_max | grep -o '[0-9]\+'
 }
 
 _require_scratch_write_atomic()
diff --git a/doc/group-names.txt b/doc/group-names.txt
index 58502131..10b49e50 100644
--- a/doc/group-names.txt
+++ b/doc/group-names.txt
@@ -12,6 +12,7 @@ acl			Access Control Lists
 admin			xfs_admin functionality
 aio			general libaio async io tests
 atime			file access time
+atomicwrites		RWF_ATOMIC testing
 attr			extended attributes
 attr2			xfs v2 extended aributes
 balance			btrfs tree rebalance
diff --git a/tests/generic/765 b/tests/generic/765
index 8695a306..84381730 100755
--- a/tests/generic/765
+++ b/tests/generic/765
@@ -7,7 +7,7 @@
 # Validate atomic write support
 #
 . ./common/preamble
-_begin_fstest auto quick rw
+_begin_fstest auto quick rw atomicwrites
 
 _require_scratch_write_atomic
 _require_xfs_io_command pwrite -A
@@ -34,6 +34,10 @@ get_supported_bsize()
         _notrun "$FSTYP does not support atomic writes"
         ;;
     esac
+
+    echo "fs config ------------" >> $seqres.full
+    echo "min_bsize $min_bsize" >> $seqres.full
+    echo "max_bsize $max_bsize" >> $seqres.full
 }
 
 get_mkfs_opts()
@@ -70,6 +74,11 @@ test_atomic_writes()
     file_max_write=$(_get_atomic_write_unit_max $testfile)
     file_max_segments=$(_get_atomic_write_segments_max $testfile)
 
+    echo "test $bsize --------------" >> $seqres.full
+    echo "file awu_min $file_min_write" >> $seqres.full
+    echo "file awu_max $file_max_write" >> $seqres.full
+    echo "file awu_segments $file_max_segments" >> $seqres.full
+
     # Check that atomic min/max = FS block size
     test $file_min_write -eq $bsize || \
         echo "atomic write min $file_min_write, should be fs block size $bsize"
@@ -145,6 +154,15 @@ test_atomic_write_bounds()
     testfile=$SCRATCH_MNT/testfile
     touch $testfile
 
+    file_min_write=$(_get_atomic_write_unit_min $testfile)
+    file_max_write=$(_get_atomic_write_unit_max $testfile)
+    file_max_segments=$(_get_atomic_write_segments_max $testfile)
+
+    echo "test awb $bsize --------------" >> $seqres.full
+    echo "file awu_min $file_min_write" >> $seqres.full
+    echo "file awu_max $file_max_write" >> $seqres.full
+    echo "file awu_segments $file_max_segments" >> $seqres.full
+
     $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile 2>> $seqres.full && \
         echo "atomic write should fail when bsize is out of bounds"
 
@@ -157,6 +175,11 @@ sys_max_write=$(cat "/sys/block/$(_short_dev $SCRATCH_DEV)/queue/atomic_write_un
 bdev_min_write=$(_get_atomic_write_unit_min $SCRATCH_DEV)
 bdev_max_write=$(_get_atomic_write_unit_max $SCRATCH_DEV)
 
+echo "sysfs awu_min $sys_min_write" >> $seqres.full
+echo "sysfs awu_min $sys_max_write" >> $seqres.full
+echo "bdev awu_min $bdev_min_write" >> $seqres.full
+echo "bdev awu_min $bdev_max_write" >> $seqres.full
+
 # Test that statx atomic values are the same as sysfs values
 if [ "$sys_min_write" -ne "$bdev_min_write" ]; then
     echo "bdev min write != sys min write"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/5] generic/765: move common atomic write code to a library file
  2025-06-02 19:22 [PATCH 0/5] atomic writes tests (part 1) Catherine Hoang
  2025-06-02 19:22 ` [PATCH 1/5] generic/765: fix a few issues Catherine Hoang
  2025-06-02 19:22 ` [PATCH 2/5] generic/765: adjust various things Catherine Hoang
@ 2025-06-02 19:22 ` Catherine Hoang
  2025-06-02 19:22 ` [PATCH 4/5] common/atomicwrites: adjust a few more things Catherine Hoang
  2025-06-02 19:22 ` [PATCH 5/5] common/atomicwrites: fix _require_scratch_write_atomic Catherine Hoang
  4 siblings, 0 replies; 8+ messages in thread
From: Catherine Hoang @ 2025-06-02 19:22 UTC (permalink / raw)
  To: linux-xfs, fstests; +Cc: djwong, john.g.garry, ritesh.list, ojaswin

From: "Darrick J. Wong" <djwong@kernel.org>

Move the common atomic writes code to common/atomicwrites so we can share
them.

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>
---
 common/atomicwrites | 111 ++++++++++++++++++++++++++++++++++++++++++++
 common/rc           |  47 -------------------
 tests/generic/765   |  53 ++-------------------
 3 files changed, 114 insertions(+), 97 deletions(-)
 create mode 100644 common/atomicwrites

diff --git a/common/atomicwrites b/common/atomicwrites
new file mode 100644
index 00000000..fd3a9b71
--- /dev/null
+++ b/common/atomicwrites
@@ -0,0 +1,111 @@
+##/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2025 Oracle.  All Rights Reserved.
+#
+# Routines for testing atomic writes.
+
+_get_atomic_write_unit_min()
+{
+	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
+        grep atomic_write_unit_min | grep -o '[0-9]\+'
+}
+
+_get_atomic_write_unit_max()
+{
+	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
+        grep -w atomic_write_unit_max | grep -o '[0-9]\+'
+}
+
+_get_atomic_write_segments_max()
+{
+	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
+        grep -w atomic_write_segments_max | grep -o '[0-9]\+'
+}
+
+_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)
+
+	if [ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]; then
+		_notrun "write atomic not supported by this block device"
+	fi
+
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+
+	testfile=$SCRATCH_MNT/testfile
+	touch $testfile
+
+	awu_min_fs=$(_get_atomic_write_unit_min $testfile)
+	awu_max_fs=$(_get_atomic_write_unit_max $testfile)
+
+	_scratch_unmount
+
+	if [ $awu_min_fs -eq 0 ] && [ $awu_max_fs -eq 0 ]; then
+		_notrun "write atomic not supported by this filesystem"
+	fi
+}
+
+_test_atomic_file_writes()
+{
+    local bsize="$1"
+    local testfile="$2"
+    local bytes_written
+    local testfile_cp="$testfile.copy"
+
+    # Check that we can perform an atomic write of len = FS block size
+    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile | \
+        grep wrote | awk -F'[/ ]' '{print $2}')
+    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
+        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"
+    fi
+
+    # Check that we can perform an atomic write on an unwritten block
+    $XFS_IO_PROG -c "falloc $bsize $bsize" $testfile
+    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize $bsize $bsize" $testfile | \
+        grep wrote | awk -F'[/ ]' '{print $2}')
+    test $bytes_written -eq $bsize || echo "atomic write to unwritten block failed"
+
+    # Check that we can perform an atomic write on a sparse hole
+    $XFS_IO_PROG -c "fpunch 0 $bsize" $testfile
+    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile | \
+        grep wrote | awk -F'[/ ]' '{print $2}')
+    test $bytes_written -eq $bsize || echo "atomic write to sparse hole failed"
+
+    # Check that we can perform an atomic write on a fully mapped block
+    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile | \
+        grep wrote | awk -F'[/ ]' '{print $2}')
+    test $bytes_written -eq $bsize || echo "atomic write to mapped block failed"
+
+    # Reject atomic write if len is out of bounds
+    $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $((bsize - 1))" $testfile 2>> $seqres.full && \
+        echo "atomic write len=$((bsize - 1)) should fail"
+    $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $((bsize + 1))" $testfile 2>> $seqres.full && \
+        echo "atomic write len=$((bsize + 1)) should fail"
+
+    # Reject atomic write when iovecs > 1
+    $XFS_IO_PROG -dc "pwrite -A -D -V2 -b $bsize 0 $bsize" $testfile 2>> $seqres.full && \
+        echo "atomic write only supports iovec count of 1"
+
+    # Reject atomic write when not using direct I/O
+    $XFS_IO_PROG -c "pwrite -A -V1 -b $bsize 0 $bsize" $testfile 2>> $seqres.full && \
+        echo "atomic write requires direct I/O"
+
+    # Reject atomic write when offset % bsize != 0
+    $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 1 $bsize" $testfile 2>> $seqres.full && \
+        echo "atomic write requires offset to be aligned to bsize"
+}
diff --git a/common/rc b/common/rc
index f7d38894..94ae3d8c 100644
--- a/common/rc
+++ b/common/rc
@@ -5443,53 +5443,6 @@ _require_scratch_btime()
 	_scratch_unmount
 }
 
-_get_atomic_write_unit_min()
-{
-	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
-        grep atomic_write_unit_min | grep -o '[0-9]\+'
-}
-
-_get_atomic_write_unit_max()
-{
-	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
-        grep -w atomic_write_unit_max | grep -o '[0-9]\+'
-}
-
-_get_atomic_write_segments_max()
-{
-	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $1 | \
-        grep -w atomic_write_segments_max | grep -o '[0-9]\+'
-}
-
-_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)
-
-	if [ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]; then
-		_notrun "write atomic not supported by this block device"
-	fi
-
-	_scratch_mkfs > /dev/null 2>&1
-	_scratch_mount
-
-	testfile=$SCRATCH_MNT/testfile
-	touch $testfile
-
-	awu_min_fs=$(_get_atomic_write_unit_min $testfile)
-	awu_max_fs=$(_get_atomic_write_unit_max $testfile)
-
-	_scratch_unmount
-
-	if [ $awu_min_fs -eq 0 ] && [ $awu_max_fs -eq 0 ]; then
-		_notrun "write atomic not supported by this filesystem"
-	fi
-}
-
 _require_inode_limits()
 {
 	if [ $(_get_free_inode $TEST_DIR) -eq 0 ]; then
diff --git a/tests/generic/765 b/tests/generic/765
index 84381730..09e9fa38 100755
--- a/tests/generic/765
+++ b/tests/generic/765
@@ -9,6 +9,8 @@
 . ./common/preamble
 _begin_fstest auto quick rw atomicwrites
 
+. ./common/atomicwrites
+
 _require_scratch_write_atomic
 _require_xfs_io_command pwrite -A
 
@@ -87,56 +89,7 @@ test_atomic_writes()
     test $file_max_segments -eq 1 || \
         echo "atomic write max segments $file_max_segments, should be 1"
 
-    # Check that we can perform an atomic write of len = FS block size
-    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile | \
-        grep wrote | awk -F'[/ ]' '{print $2}')
-    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
-        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"
-    fi
-
-    # Check that we can perform an atomic write on an unwritten block
-    $XFS_IO_PROG -c "falloc $bsize $bsize" $testfile
-    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize $bsize $bsize" $testfile | \
-        grep wrote | awk -F'[/ ]' '{print $2}')
-    test $bytes_written -eq $bsize || echo "atomic write to unwritten block failed"
-
-    # Check that we can perform an atomic write on a sparse hole
-    $XFS_IO_PROG -c "fpunch 0 $bsize" $testfile
-    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile | \
-        grep wrote | awk -F'[/ ]' '{print $2}')
-    test $bytes_written -eq $bsize || echo "atomic write to sparse hole failed"
-
-    # Check that we can perform an atomic write on a fully mapped block
-    bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile | \
-        grep wrote | awk -F'[/ ]' '{print $2}')
-    test $bytes_written -eq $bsize || echo "atomic write to mapped block failed"
-
-    # Reject atomic write if len is out of bounds
-    $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $((bsize - 1))" $testfile 2>> $seqres.full && \
-        echo "atomic write len=$((bsize - 1)) should fail"
-    $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $((bsize + 1))" $testfile 2>> $seqres.full && \
-        echo "atomic write len=$((bsize + 1)) should fail"
-
-    # Reject atomic write when iovecs > 1
-    $XFS_IO_PROG -dc "pwrite -A -D -V2 -b $bsize 0 $bsize" $testfile 2>> $seqres.full && \
-        echo "atomic write only supports iovec count of 1"
-
-    # Reject atomic write when not using direct I/O
-    $XFS_IO_PROG -c "pwrite -A -V1 -b $bsize 0 $bsize" $testfile 2>> $seqres.full && \
-        echo "atomic write requires direct I/O"
-
-    # Reject atomic write when offset % bsize != 0
-    $XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 1 $bsize" $testfile 2>> $seqres.full && \
-        echo "atomic write requires offset to be aligned to bsize"
+    _test_atomic_file_writes "$bsize" "$testfile"
 
     _scratch_unmount
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/5] common/atomicwrites: adjust a few more things
  2025-06-02 19:22 [PATCH 0/5] atomic writes tests (part 1) Catherine Hoang
                   ` (2 preceding siblings ...)
  2025-06-02 19:22 ` [PATCH 3/5] generic/765: move common atomic write code to a library file Catherine Hoang
@ 2025-06-02 19:22 ` Catherine Hoang
  2025-06-02 19:22 ` [PATCH 5/5] common/atomicwrites: fix _require_scratch_write_atomic Catherine Hoang
  4 siblings, 0 replies; 8+ messages in thread
From: Catherine Hoang @ 2025-06-02 19:22 UTC (permalink / raw)
  To: linux-xfs, fstests; +Cc: djwong, john.g.garry, ritesh.list, ojaswin

From: "Darrick J. Wong" <djwong@kernel.org>

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>
---
 common/atomicwrites | 18 +++++++++++-------
 tests/generic/765   |  2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/common/atomicwrites b/common/atomicwrites
index fd3a9b71..9ec1ca68 100644
--- a/common/atomicwrites
+++ b/common/atomicwrites
@@ -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"
diff --git a/tests/generic/765 b/tests/generic/765
index 09e9fa38..71604e5e 100755
--- a/tests/generic/765
+++ b/tests/generic/765
@@ -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()
 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/5] common/atomicwrites: fix _require_scratch_write_atomic
  2025-06-02 19:22 [PATCH 0/5] atomic writes tests (part 1) Catherine Hoang
                   ` (3 preceding siblings ...)
  2025-06-02 19:22 ` [PATCH 4/5] common/atomicwrites: adjust a few more things Catherine Hoang
@ 2025-06-02 19:22 ` Catherine Hoang
  2025-06-12  7:07   ` Ojaswin Mujoo
  4 siblings, 1 reply; 8+ messages in thread
From: Catherine Hoang @ 2025-06-02 19:22 UTC (permalink / raw)
  To: linux-xfs, fstests; +Cc: djwong, john.g.garry, ritesh.list, ojaswin

From: "Darrick J. Wong" <djwong@kernel.org>

Fix this function to call _notrun whenever something fails.  If we can't
figure out the atomic write geometry, then we haven't satisfied the
preconditions for the test.

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>
---
 common/atomicwrites | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/common/atomicwrites b/common/atomicwrites
index 9ec1ca68..391bb6f6 100644
--- a/common/atomicwrites
+++ b/common/atomicwrites
@@ -28,21 +28,23 @@ _require_scratch_write_atomic()
 {
 	_require_scratch
 
-	awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
-	awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
+	local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
+	local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
 
 	if [ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]; then
 		_notrun "write atomic not supported by this block device"
 	fi
 
-	_scratch_mkfs > /dev/null 2>&1
-	_scratch_mount
+	_scratch_mkfs > /dev/null 2>&1 || \
+		_notrun "cannot format scratch device for atomic write checks"
+	_try_scratch_mount || \
+		_notrun "cannot mount scratch device for atomic write checks"
 
-	testfile=$SCRATCH_MNT/testfile
+	local testfile=$SCRATCH_MNT/testfile
 	touch $testfile
 
-	awu_min_fs=$(_get_atomic_write_unit_min $testfile)
-	awu_max_fs=$(_get_atomic_write_unit_max $testfile)
+	local awu_min_fs=$(_get_atomic_write_unit_min $testfile)
+	local awu_max_fs=$(_get_atomic_write_unit_max $testfile)
 
 	_scratch_unmount
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/5] generic/765: fix a few issues
  2025-06-02 19:22 ` [PATCH 1/5] generic/765: fix a few issues Catherine Hoang
@ 2025-06-04 13:58   ` John Garry
  0 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2025-06-04 13:58 UTC (permalink / raw)
  To: Catherine Hoang, linux-xfs, fstests; +Cc: djwong, ritesh.list, ojaswin

On 02/06/2025 20:22, Catherine Hoang wrote:
> From: "Darrick J. Wong"<djwong@kernel.org>
> 
> Fix a few bugs in the single block atomic writes test, such as not requiring
> directio, using the page size for the ext4 max bsize, and making sure we check
> the max atomic write size.
> 
> Cc:ritesh.list@gmail.com
> Signed-off-by: Catherine Hoang<catherine.hoang@oracle.com>
> Reviewed-by: "Darrick J. Wong"<djwong@kernel.org>
> Signed-off-by: "Darrick J. Wong"<djwong@kernel.org>
> Reviewed-by: Ritesh Harjani (IBM)<ritesh.list@gmail.com>
> Reviewed-by: Ojaswin Mujoo<ojaswin@linux.ibm.com>
> ---

Reviewed-by: John Garry <john.g.garry@oracle.com>

BTW, it would have been nice to keep the series versioning as before, as 
this is really the same series, thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] common/atomicwrites: fix _require_scratch_write_atomic
  2025-06-02 19:22 ` [PATCH 5/5] common/atomicwrites: fix _require_scratch_write_atomic Catherine Hoang
@ 2025-06-12  7:07   ` Ojaswin Mujoo
  0 siblings, 0 replies; 8+ messages in thread
From: Ojaswin Mujoo @ 2025-06-12  7:07 UTC (permalink / raw)
  To: Catherine Hoang; +Cc: linux-xfs, fstests, djwong, john.g.garry, ritesh.list

On Mon, Jun 02, 2025 at 12:22:14PM -0700, Catherine Hoang wrote:
> From: "Darrick J. Wong" <djwong@kernel.org>
> 
> Fix this function to call _notrun whenever something fails.  If we can't
> figure out the atomic write geometry, then we haven't satisfied the
> preconditions for the test.
> 
> 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>
> ---
>  common/atomicwrites | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/common/atomicwrites b/common/atomicwrites
> index 9ec1ca68..391bb6f6 100644
> --- a/common/atomicwrites
> +++ b/common/atomicwrites
> @@ -28,21 +28,23 @@ _require_scratch_write_atomic()
>  {
>  	_require_scratch
>  
> -	awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
> -	awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
> +	local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
> +	local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
>  
>  	if [ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]; then
>  		_notrun "write atomic not supported by this block device"
>  	fi
>  
> -	_scratch_mkfs > /dev/null 2>&1
> -	_scratch_mount
> +	_scratch_mkfs > /dev/null 2>&1 || \
> +		_notrun "cannot format scratch device for atomic write checks"
> +	_try_scratch_mount || \
> +		_notrun "cannot mount scratch device for atomic write checks"
>  
> -	testfile=$SCRATCH_MNT/testfile
> +	local testfile=$SCRATCH_MNT/testfile
>  	touch $testfile
>  
> -	awu_min_fs=$(_get_atomic_write_unit_min $testfile)
> -	awu_max_fs=$(_get_atomic_write_unit_max $testfile)
> +	local awu_min_fs=$(_get_atomic_write_unit_min $testfile)
> +	local awu_max_fs=$(_get_atomic_write_unit_max $testfile)
>  
>  	_scratch_unmount

Looks good, feel free to add:

Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>

Regards,
ojaswin
>  
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-12  7:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-02 19:22 [PATCH 0/5] atomic writes tests (part 1) Catherine Hoang
2025-06-02 19:22 ` [PATCH 1/5] generic/765: fix a few issues Catherine Hoang
2025-06-04 13:58   ` John Garry
2025-06-02 19:22 ` [PATCH 2/5] generic/765: adjust various things Catherine Hoang
2025-06-02 19:22 ` [PATCH 3/5] generic/765: move common atomic write code to a library file Catherine Hoang
2025-06-02 19:22 ` [PATCH 4/5] common/atomicwrites: adjust a few more things Catherine Hoang
2025-06-02 19:22 ` [PATCH 5/5] common/atomicwrites: fix _require_scratch_write_atomic Catherine Hoang
2025-06-12  7:07   ` Ojaswin Mujoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).