All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catherine Hoang <catherine.hoang@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH v1] xfs: add a test for atomic writes
Date: Thu, 12 Dec 2024 15:01:23 -0800	[thread overview]
Message-ID: <20241212230123.36325-1-catherine.hoang@oracle.com> (raw)

Add a test to validate the new atomic writes feature.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
---
 common/rc         | 14 ++++++++++++++
 tests/xfs/611     | 48 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/611.out | 17 +++++++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100755 tests/xfs/611
 create mode 100644 tests/xfs/611.out

diff --git a/common/rc b/common/rc
index 2ee46e51..b9da749e 100644
--- a/common/rc
+++ b/common/rc
@@ -5148,6 +5148,20 @@ _require_scratch_btime()
 	_scratch_unmount
 }
 
+_require_scratch_write_atomic()
+{
+	_require_scratch
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+
+	export STATX_WRITE_ATOMIC=0x10000
+	$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_MNT \
+		| grep atomic >>$seqres.full 2>&1 || \
+		_notrun "write atomic not supported by this filesystem"
+
+	_scratch_unmount
+}
+
 _require_inode_limits()
 {
 	if [ $(_get_free_inode $TEST_DIR) -eq 0 ]; then
diff --git a/tests/xfs/611 b/tests/xfs/611
new file mode 100755
index 00000000..d193de86
--- /dev/null
+++ b/tests/xfs/611
@@ -0,0 +1,48 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle.  All Rights Reserved.
+#
+# FS QA Test 611
+#
+# Validate atomic write support
+#
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_supported_fs xfs
+_require_scratch
+_require_scratch_write_atomic
+
+test_atomic_writes()
+{
+    bsize=$1
+
+    echo ""
+    echo "Block size: $bsize"
+
+    _scratch_mkfs_xfs -b size=$bsize >> $seqres.full
+    _scratch_mount
+
+    testfile=$SCRATCH_MNT/testfile
+    touch $testfile
+
+    # Check that atomic min/max = FS block size
+    $XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $testfile \
+        | grep atomic
+
+    # Check that we can perform an atomic write of len = FS block size
+    $XFS_IO_PROG -dc "pwrite -A -D 0 $bsize" $testfile | grep wrote
+
+    # Reject atomic write if len is out of bounds
+    $XFS_IO_PROG -dc "pwrite -A -D 0 $((bsize - 1))" $testfile
+    $XFS_IO_PROG -dc "pwrite -A -D 0 $((bsize + 1))" $testfile
+
+    _scratch_unmount
+}
+
+test_atomic_writes 4096
+test_atomic_writes 16384
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/611.out b/tests/xfs/611.out
new file mode 100644
index 00000000..ea28b971
--- /dev/null
+++ b/tests/xfs/611.out
@@ -0,0 +1,17 @@
+QA output created by 611
+
+Block size: 4096
+stat.atomic_write_unit_min = 4096
+stat.atomic_write_unit_max = 4096
+stat.atomic_write_segments_max = 1
+wrote 4096/4096 bytes at offset 0
+pwrite: Invalid argument
+pwrite: Invalid argument
+
+Block size: 16384
+stat.atomic_write_unit_min = 16384
+stat.atomic_write_unit_max = 16384
+stat.atomic_write_segments_max = 1
+wrote 16384/16384 bytes at offset 0
+pwrite: Invalid argument
+pwrite: Invalid argument
-- 
2.34.1


             reply	other threads:[~2024-12-12 23:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 23:01 Catherine Hoang [this message]
2024-12-12 23:16 ` [PATCH v1] xfs: add a test for atomic writes Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241212230123.36325-1-catherine.hoang@oracle.com \
    --to=catherine.hoang@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.