Catherine Hoang <catherine.hoang@xxxxxxxxxx> writes: > Add a test to validate the new atomic writes feature. Thanks! > > Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx> > --- > common/rc | 14 ++++++++ > tests/xfs/611 | 81 +++++++++++++++++++++++++++++++++++++++++++++++ > tests/xfs/611.out | 2 ++ > 3 files changed, 97 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..a26ec143 > --- /dev/null > +++ b/tests/xfs/611 > @@ -0,0 +1,81 @@ > +#! /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() > +{ > + local bsize=$1 > + > + _scratch_mkfs_xfs -b size=$bsize >> $seqres.full > + _scratch_mount > + _xfs_force_bdev data $SCRATCH_MNT > + > + testfile=$SCRATCH_MNT/testfile > + touch $testfile > + > + file_min_write=$($XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $testfile | \ > + grep atomic_write_unit_min | cut -d ' ' -f 3) > + file_max_write=$($XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $testfile | \ > + grep atomic_write_unit_max | cut -d ' ' -f 3) > + file_max_segments=$($XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $testfile | \ > + grep atomic_write_segments_max | cut -d ' ' -f 3) > + > + # 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 || \ > + 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" > + > + # Check that we can perform an atomic write of len = FS block size > + bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D 0 $bsize" $testfile | \ Shouldn't we also have something like below to see whether pwrite supports -A option or not? _require_xfs_io_command pwrite -A So maybe like this? common/rc: Add support to validate -A option for pwrite diff --git a/common/rc b/common/rc index 6592c835..36fbaa53 100644 --- a/common/rc +++ b/common/rc @@ -2837,6 +2837,13 @@ _require_xfs_io_command() opts+=" -d" pwrite_opts+="-V 1 -b 4k" fi + # Let's check if -A option is supported in xfs_io or not + if [ "$param" == "-A" ]; then + testio=$($XFS_IO_PROG -f -d -c \ + "pwrite -V 1 -b 4k -A 0 4k" $testfile 2>&1) + echo $testio |grep -q "invalid option" && \ + _notrun "xfs_io $command $param support is missing" + fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1` param_checked="$pwrite_opts $param" > + grep wrote | awk -F'[/ ]' '{print $2}') > + test $bytes_written -eq $bsize || echo "atomic write len=$bsize failed" -ritesh