atomic writes tests
cover atomic writes tests
Hi all,
Now that large atomic writes has been queued up, here's a series of tests for this new feature. The first few patches make various adjustments to the existing single block atomic writes test, as well as setup for additional testing. The last patch adds several new tests for large atomic writes with actual and simulated hardware.
This series is based on for-next at the time of sending.
Comments and feedback appreciated!
Darrick J. Wong (6):
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
generic: various atomic write tests with scsi_debug
common/atomicwrites | 127 +++++++++++++++++++++++++++++++++++++ common/rc | 49 +-------------- doc/group-names.txt | 1 + tests/generic/1222 | 86 +++++++++++++++++++++++++ tests/generic/1222.out | 10 +++ tests/generic/1223 | 66 +++++++++++++++++++ tests/generic/1223.out | 9 +++ tests/generic/1224 | 140 +++++++++++++++++++++++++++++++++++++++++ tests/generic/1224.out | 17 +++++ tests/generic/1225 | 51 +++++++++++++++ tests/generic/1225.out | 1 + tests/generic/765 | 84 +++++++++---------------- tests/xfs/1216 | 68 ++++++++++++++++++++ tests/xfs/1216.out | 9 +++ tests/xfs/1217 | 70 +++++++++++++++++++++ tests/xfs/1217.out | 3 + tests/xfs/1218 | 59 +++++++++++++++++ tests/xfs/1218.out | 15 +++++ 18 files changed, 763 insertions(+), 102 deletions(-) create mode 100644 common/atomicwrites create mode 100755 tests/generic/1222 create mode 100644 tests/generic/1222.out create mode 100755 tests/generic/1223 create mode 100644 tests/generic/1223.out create mode 100644 tests/generic/1224 create mode 100644 tests/generic/1224.out create mode 100644 tests/generic/1225 create mode 100644 tests/generic/1225.out create mode 100755 tests/xfs/1216 create mode 100644 tests/xfs/1216.out create mode 100755 tests/xfs/1217 create mode 100644 tests/xfs/1217.out create mode 100644 tests/xfs/1218 create mode 100644 tests/xfs/1218.out
Signature · 1 line
2.34.1
PATCH 1/6 generic/765: fix a few issues
From: "Darrick J. Wong" <[email protected]>
Fix a few bugs in the single block atomic writes test, such as requiring directio, using page size for the ext4 max bsize, and making sure we check the max atomic write size.
--- common/rc | 2 +- tests/generic/765 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
common/rc +1 -1
@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k" fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`
tests/generic/765 +2 -2
@@ -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"
Signature · 1 line
2.34.1
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 20 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Fix a few bugs in the single block atomic writes test, such as requiring directio, using page size for the ext4 max bsize, and making sure we check the max atomic write size.
Signed-off-by Catherine Hoang <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Signed-off-by "Darrick J. Wong" <[email protected]>--- common/rc | 2 +- tests/generic/765 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)common/rc +0
-0
common/rc _require_xfs_io_command() · line 2992
Quoted 5 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"
according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
And setting -d in pwrite_opts means DIO for the input file, right? I am not sure if that is required.
tests/generic/765 get_supported_bsize() · line 31
Quoted 13 lines
common/rc +0
-0fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`tests/generic/765 +1
-1@@ -28,7 +28,7 @@ get_supported_bsize() ;; "ext4") min_bsize=1024 - max_bsize=4096 + max_bsize=$(_get_page_size)
looks ok
tests/generic/765 test_atomic_writes() · line 76
Quoted 9 lines
tests/generic/765 +1
-1;; *) _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 || \
looks ok
tests/generic/765 test_atomic_writes() · line 79
Quoted 3 lines
tests/generic/765 +0
-0echo "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"
Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 16 lines · John Garry
Quoted 15 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Fix a few bugs in the single block atomic writes test, such as requiring directio, using page size for the ext4 max bsize, and making sure we check the max atomic write size.
Signed-off-by Catherine Hoang <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Signed-off-by "Darrick J. Wong" <[email protected]>--- common/rc | 2 +- tests/generic/765 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Quoted 14 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 10 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Quoted 2 lines
And setting -d in
pwrite_optsmeans DIO for the input file, right? I am not sure if that is required.
It's not required, I mistook where that "-d" goes -- -d as an argument to xfs_io is necessary, but -d as an argument to the pwrite subcommand is not. It's also benign since we don't pass -i.
Curiously the version of this patch in my tree doesn't have the extra -d... I wonder if I made that change and forgot to send it out.
--D
Quoted 36 lines
tests/generic/765 get_supported_bsize() · line 31
Quoted 13 lines
common/rc +0
-0fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`tests/generic/765 +1
-1@@ -28,7 +28,7 @@ get_supported_bsize() ;; "ext4") min_bsize=1024 - max_bsize=4096 + max_bsize=$(_get_page_size)looks ok
tests/generic/765 test_atomic_writes() · line 76
Quoted 9 lines
tests/generic/765 +1
-1;; *) _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 || \looks ok
tests/generic/765 test_atomic_writes() · line 79
Quoted 3 lines
tests/generic/765 +0
-0echo "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"Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 40 lines · Darrick J. Wong
Quoted 16 lines · John Garry
Quoted 15 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Fix a few bugs in the single block atomic writes test, such as requiring directio, using page size for the ext4 max bsize, and making sure we check the max atomic write size.
Signed-off-by Catherine Hoang <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Signed-off-by "Darrick J. Wong" <[email protected]>--- common/rc | 2 +- tests/generic/765 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)Quoted 14 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 10 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Quoted 2 lines
And setting -d in
pwrite_optsmeans DIO for the input file, right? I am not sure if that is required.
Quoted 6 lines
It's not required, I mistook where that "-d" goes -- -d as an argument to
xfs_iois necessary, but -d as an argument to the pwrite subcommand is not. It's also benign since we don't pass -i.Curiously the version of this patch in my tree doesn't have the extra -d... I wonder if I made that change and forgot to send it out.
Hmm, it might have been from an old patch on my branch that I forgot to update when I sent this out. Just to clarify, this should just be
pwrite_opts+="-V 1 -b 4k”
right?
Quoted 38 lines
--D
Quoted 35 lines
tests/generic/765 get_supported_bsize() · line 31
Quoted 13 lines
common/rc +0
-0fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`tests/generic/765 +1
-1@@ -28,7 +28,7 @@ get_supported_bsize() ;; "ext4") min_bsize=1024 - max_bsize=4096 + max_bsize=$(_get_page_size)looks ok
tests/generic/765 test_atomic_writes() · line 76
Quoted 9 lines
tests/generic/765 +1
-1;; *) _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 || \looks ok
tests/generic/765 test_atomic_writes() · line 79
Quoted 3 lines
tests/generic/765 +0
-0echo "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"Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 47 lines · Catherine Hoang
Quoted 40 lines · Darrick J. Wong
Quoted 16 lines · John Garry
Quoted 15 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Fix a few bugs in the single block atomic writes test, such as requiring directio, using page size for the ext4 max bsize, and making sure we check the max atomic write size.
Signed-off-by Catherine Hoang <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Signed-off-by "Darrick J. Wong" <[email protected]>--- common/rc | 2 +- tests/generic/765 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)Quoted 14 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 10 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Quoted 2 lines
And setting -d in
pwrite_optsmeans DIO for the input file, right? I am not sure if that is required.Quoted 6 lines
It's not required, I mistook where that "-d" goes -- -d as an argument to
xfs_iois necessary, but -d as an argument to the pwrite subcommand is not. It's also benign since we don't pass -i.Curiously the version of this patch in my tree doesn't have the extra -d... I wonder if I made that change and forgot to send it out.
Quoted 7 lines
Hmm, it might have been from an old patch on my branch that I forgot to update when I sent this out. Just to clarify, this should just be
pwrite_opts+="-V 1 -b 4k”
right?
Yep.
--D
Quoted 39 lines
Quoted 37 lines
--D
Quoted 35 lines
tests/generic/765 get_supported_bsize() · line 31
Quoted 13 lines
common/rc +0
-0fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`tests/generic/765 +1
-1@@ -28,7 +28,7 @@ get_supported_bsize() ;; "ext4") min_bsize=1024 - max_bsize=4096 + max_bsize=$(_get_page_size)looks ok
tests/generic/765 test_atomic_writes() · line 76
Quoted 9 lines
tests/generic/765 +1
-1;; *) _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 || \looks ok
tests/generic/765 test_atomic_writes() · line 79
Quoted 3 lines
tests/generic/765 +0
-0echo "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"Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
In reply to Darrick J. WongQuoted 11 lines · Darrick J. Wong
Quoted 11 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 8 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
Quoted 2 lines
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Right, I see that in init_cvtnum()
However, from checking write_buffer(), we seem to split writes on this blocksize - that does not seem proper in this instance.
Should we really be doing something like:
xfs_io -d -C "pwrite -b $SIZE -V 1 -A -D 0 $SIZE" file
Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 15 lines · John Garry
Quoted 11 lines · Darrick J. Wong
Quoted 11 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 8 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
Quoted 2 lines
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Quoted 8 lines
Right, I see that in
init_cvtnum()However, from checking
write_buffer(), we seem to split writes on this blocksize - that does not seem proper in this instance.Should we really be doing something like:
xfs_io-d -C "pwrite -b $SIZE -V 1 -A -D 0 $SIZE" file
In _require_xfs_io_command? That only writes the first 4k of a file, so matching buffer size is ok.
Are you asking if _require_xfs_io_command should seek out the filesystem block size, and use that for the buffer and write size arguments instead of hardcoding 4k? For atomic writes, maybe it should be doing this, since the fs blocksize could be 64k.
--D
Quoted 3 lines
Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 21 lines · Darrick J. Wong
Quoted 20 lines · John Garry
Quoted 11 lines · Darrick J. Wong
Quoted 11 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 8 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
Quoted 2 lines
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Right, I see that in
init_cvtnum()However, from checking
write_buffer(), we seem to split writes on this blocksize - that does not seem proper in this instance.
Quoted 6 lines
Quoted 3 lines
Should we really be doing something like:
xfs_io-d -C "pwrite -b $SIZE -V 1 -A -D 0 $SIZE" fileIn
_require_xfs_io_command? That only writes the first 4k of a file, so matching buffer size is ok.
right, I missed that. The usage in _require_xfs_io_command looks ok.
Quoted 6 lines
Are you asking if
_require_xfs_io_commandshould seek out the filesystem block size, and use that for the buffer and write size arguments instead of hardcoding 4k? For atomic writes, maybe it should be doing this, since the fs blocksize could be 64k.
I was just a bit thrown by how we need to specify -b $size with -A to actually write $size atomically.
Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 30 lines · John Garry
Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · John Garry
Quoted 11 lines · Darrick J. Wong
Quoted 11 lines
common/rc _require_xfs_io_command() · line 2992
Quoted 8 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"according to the documentation for -b, 4096 is the default (so I don't think that we need to set it explicitly). But is that flag even relevant to pwritev2?
Quoted 2 lines
The documentation is wrong -- on XFS the default is the fs blocksize. Everywhere else is 4k.
Right, I see that in
init_cvtnum()Quoted 8 lines
Quoted 6 lines
However, from checking
write_buffer(), we seem to split writes on this blocksize - that does not seem proper in this instance.Should we really be doing something like:
xfs_io-d -C "pwrite -b $SIZE -V 1 -A -D 0 $SIZE" fileIn
_require_xfs_io_command? That only writes the first 4k of a file, so matching buffer size is ok.
Quoted 8 lines
right, I missed that. The usage in
_require_xfs_io_commandlooks ok.Quoted 4 lines
Are you asking if
_require_xfs_io_commandshould seek out the filesystem block size, and use that for the buffer and write size arguments instead of hardcoding 4k? For atomic writes, maybe it should be doing this, since the fs blocksize could be 64k.I was just a bit thrown by how we need to specify -b $size with -A to actually write $size atomically.
There was a discussion about this a while back about why -b $bsize was needed when using pwrite, although I’m not sure if it still applies or if the way atomic writes works has been changed since then.
https://lore.kernel.org/linux-xfs/[email protected]/
Quoted 3 lines
Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
Quoted 10 lines · Catherine Hoang
Quoted 5 lines
Quoted 4 lines
Are you asking if
_require_xfs_io_commandshould seek out the filesystem block size, and use that for the buffer and write size arguments instead of hardcoding 4k? For atomic writes, maybe it should be doing this, since the fs blocksize could be 64k.I was just a bit thrown by how we need to specify -b $size with -A to actually write $size atomically.
There was a discussion about this a while back about why -b $bsize was needed when using pwrite, although I’m not sure if it still applies or if the way atomic writes works has been changed since then.
Yes, and the xfs_io behaviour for -A is my focus here. I don't like how it splits by default (for $size > default blocksize).
We could have had behaviour that default blocksize for -A is $size. Maybe that just complicates things. Anyway, I think that ship has sailed.
Thanks,
John
Re: [PATCH 1/6] generic/765: fix a few issues
In reply to Catherine HoangQuoted 20 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Fix a few bugs in the single block atomic writes test, such as requiring directio, using page size for the ext4 max bsize, and making sure we check the max atomic write size.
Signed-off-by Catherine Hoang <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Signed-off-by "Darrick J. Wong" <[email protected]>--- common/rc | 2 +- tests/generic/765 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)common/rc +0
-0
common/rc _require_xfs_io_command() · line 2992
Quoted 5 lines
common/rc +1
-1@@ -2989,7 +2989,7 @@ _require_xfs_io_command() fi if [ "$param" == "-A" ]; then opts+=" -d" - pwrite_opts+="-D -V 1 -b 4k" + pwrite_opts+="-d -V 1 -b 4k"
I guess the discussion already happened that this needs fixing.
Quoted 27 lines
common/rc +0
-0fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1`tests/generic/765 +2
-2@@ -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"Signature · 1 line
2.34.1
Otherwise the changes looks good. Thanks for fixing this!
-ritesh
PATCH 2/6 generic/765: adjust various things
In reply to Catherine HoangFrom: "Darrick J. Wong" <[email protected]>
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.
--- common/rc | 4 ++-- doc/group-names.txt | 1 + tests/generic/765 | 25 ++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-)
common/rc +2 -2
@@ -5442,13 +5442,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()
doc/group-names.txt +1 -0
@@ -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
tests/generic/765 +24 -1
@@ -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"
Signature · 1 line
2.34.1
Re: [PATCH 2/6] generic/765: adjust various things
Quoted 8 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
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" <[email protected]>Signed-off-by Catherine Hoang <[email protected]>
Just a small comment below
cheers
tests/generic/765 test_atomic_writes() · line 80
Quoted 11 lines
}
get_mkfs_opts()tests/generic/765 +4
-0@@ -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
We should prob report and test atomic write unit max opt also when it's available officially in stat.h
Re: [PATCH 2/6] generic/765: adjust various things
In reply to Catherine HoangQuoted 39 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
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" <[email protected]>Signed-off-by Catherine Hoang <[email protected]>--- common/rc | 4 ++-- doc/group-names.txt | 1 + tests/generic/765 | 25 ++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-)common/rc +2
-2@@ -5442,13 +5442,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()doc/group-names.txt +0
-0
doc/group-names.txt acl Access Control Lists · line 15
Quoted 4 lines
doc/group-names.txt +1
-0@@ -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
NIT: I wish we could have a shorter name for this? atomicwr or awio (Atomic write I/O)
Either ways, the changes looks logical to me. It's good to have these various atomic units in $seqres.full file for later debugging.
Please feel free to add:
-ritesh
PATCH 3/6 generic/765: move common atomic write code to a library file
In reply to Catherine HoangFrom: "Darrick J. Wong" <[email protected]>
Move the common atomic writes code to common/atomic so we can share them.
--- common/atomicwrites | 111 ++++++++++++++++++++++++++++++++++++++++++++ common/rc | 47 ------------------- tests/generic/765 | 53 ++------------------- 3 files changed, 114 insertions(+), 97 deletions(-) create mode 100644 common/atomicwrites
common/atomicwrites new file +111 -0
@@ -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" +}
common/rc +0 -47
53 lines not on this page · raw message
tests/generic/765 +3 -50
65 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 3/6] generic/765: move common atomic write code to a library file
Quoted 7 lines · Catherine Hoang
From: "Darrick J. Wong"<[email protected]>
Move the common atomic writes code to common/atomic so we can share them.
Signed-off-by "Darrick J. Wong"<[email protected]>Signed-off-by Catherine Hoang<[email protected]>
Re: [PATCH 3/6] generic/765: move common atomic write code to a library file
In reply to Catherine HoangQuoted 35 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Move the common atomic writes code to common/atomic so we can share them.
Signed-off-by "Darrick J. Wong" <[email protected]>Signed-off-by Catherine Hoang <[email protected]>--- common/atomicwrites | 111 ++++++++++++++++++++++++++++++++++++++++++++ common/rc | 47 ------------------- tests/generic/765 | 53 ++------------------- 3 files changed, 114 insertions(+), 97 deletions(-) create mode 100644 common/atomicwritescommon/atomicwrites new file +15
-0@@ -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 | \
common/atomicwrites line 25
Quoted 10 lines
common/atomicwrites new file +10
-0+ 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()
NIT: It would be more convenient if we had this as _require_scratch_atomic_write()
Quoted 202 lines
common/atomicwrites new file +86
-0+{ + _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" +}common/rc +0
-47@@ -5433,53 +5433,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 ]; thentests/generic/765 +2
-41@@ -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 && \
tests/generic/765 test_atomic_writes() · line 92
Quoted 10 lines
tests/generic/765 +1
-9- 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"
I see this must be done since in later patches we are adding an atomic write test using scsi debug.
Sure make sense in that case. Please feel free to add:
-ritesh
Quoted 5 lines
tests/generic/765 +0
-0_scratch_unmount }Signature · 1 line
2.34.1
PATCH 4/6 common/atomicwrites: adjust a few more things
In reply to Catherine HoangFrom: "Darrick J. Wong" <[email protected]>
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.
--- common/atomicwrites | 18 +++++++++++------- tests/generic/765 | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-)
common/atomicwrites +11 -7
@@ -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"
tests/generic/765 +1 -1
@@ -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() {
Signature · 1 line
2.34.1
Re: [PATCH 4/6] common/atomicwrites: adjust a few more things
Quoted 8 lines · Catherine Hoang
From: "Darrick J. Wong"<[email protected]>
Always export
STATX_WRITE_ATOMICso 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 necessaryxfs_iosupport is present.Signed-off-by "Darrick J. Wong"<[email protected]>Signed-off-by Catherine Hoang<[email protected]>
Just a small comment query below.
Quoted 43 lines
--- common/atomicwrites | 18 +++++++++++------- tests/generic/765 | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-)common/atomicwrites +10
-2@@ -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"
common/atomicwrites _test_atomic_file_writes() · line 75
Quoted 9 lines
common/atomicwrites +1
-5@@ -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
I suppose that previously for xfs where the cp --reflink failed, we would pointlessly try the write - am I correct?
If so, now seems much better.
Quoted 1 line
common/atomicwrites +0
-0bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile_cp | \
Re: [PATCH 4/6] common/atomicwrites: adjust a few more things
Quoted 56 lines · John Garry
Quoted 8 lines · Catherine Hoang
From: "Darrick J. Wong"<[email protected]>
Always export
STATX_WRITE_ATOMICso 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 necessaryxfs_iosupport is present.Signed-off-by "Darrick J. Wong"<[email protected]>Signed-off-by Catherine Hoang<[email protected]>Just a small comment query below.
Reviewed-by John Garry <[email protected]>Quoted 42 lines
--- common/atomicwrites | 18 +++++++++++------- tests/generic/765 | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-)common/atomicwrites +10
-3@@ -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
Quoted 8 lines
common/atomicwrites _test_atomic_file_writes() · line 75
Quoted 5 lines
common/atomicwrites +1
-4- 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; thenI suppose that previously for xfs where the cp --reflink failed, we would pointlessly try the write - am I correct?
Correct.
Quoted 1 line
If so, now seems much better.
That and any filesystem that supports reflink and atomic writes will now test this. :)
Thanks for review!
--D
Quoted 3 lines
Quoted 1 line
common/atomicwrites +0
-0bytes_written=$($XFS_IO_PROG -dc "pwrite -A -D -V1 -b $bsize 0 $bsize" $testfile_cp | \
Re: [PATCH 4/6] common/atomicwrites: adjust a few more things
In reply to Catherine HoangQuoted 18 lines · Catherine Hoang
From: "Darrick J. Wong" <[email protected]>
Always export
STATX_WRITE_ATOMICso 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 necessaryxfs_iosupport is present.Signed-off-by "Darrick J. Wong" <[email protected]>Signed-off-by Catherine Hoang <[email protected]>--- common/atomicwrites | 18 +++++++++++------- tests/generic/765 | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-)common/atomicwrites +0
-0
common/atomicwrites line 8
Quoted 5 lines
common/atomicwrites +2
-0@@ -4,6 +4,8 @@ # # Routines for testing atomic writes. +export STATX_WRITE_ATOMIC=0x10000 +
Finally we have this exported. Thanks for doing this :)
The changes looks good to me. Please feel free to add:
Quoted 55 lines
common/atomicwrites +9
-7_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"tests/generic/765 +1
-1@@ -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() {Signature · 1 line
2.34.1
PATCH 5/6 common/atomicwrites: fix _require_scratch_write_atomic
In reply to Catherine HoangFrom: "Darrick J. Wong" <[email protected]>
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.
--- common/atomicwrites | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
common/atomicwrites +9 -7
@@ -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
Signature · 1 line
2.34.1
Re: [PATCH 5/6] common/atomicwrites: fix _require_scratch_write_atomic
Quoted 8 lines · Catherine Hoang
From: "Darrick J. Wong"<[email protected]>
Fix this function to call
_notrunwhenever 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"<[email protected]>Signed-off-by Catherine Hoang<[email protected]>
PATCH 6/6 generic: various atomic write tests with scsi_debug
In reply to Catherine HoangFrom: "Darrick J. Wong" <[email protected]>
Simple tests of various atomic write requests and a (simulated) hardware device.
--- common/atomicwrites | 10 +++ tests/generic/1222 | 86 +++++++++++++++++++++++++ tests/generic/1222.out | 10 +++ tests/generic/1223 | 66 +++++++++++++++++++ tests/generic/1223.out | 9 +++ tests/generic/1224 | 140 +++++++++++++++++++++++++++++++++++++++++ tests/generic/1224.out | 17 +++++ tests/generic/1225 | 51 +++++++++++++++ tests/generic/1225.out | 1 + tests/xfs/1216 | 68 ++++++++++++++++++++ tests/xfs/1216.out | 9 +++ tests/xfs/1217 | 70 +++++++++++++++++++++ tests/xfs/1217.out | 3 + tests/xfs/1218 | 59 +++++++++++++++++ tests/xfs/1218.out | 15 +++++ 15 files changed, 614 insertions(+) create mode 100755 tests/generic/1222 create mode 100644 tests/generic/1222.out create mode 100755 tests/generic/1223 create mode 100644 tests/generic/1223.out create mode 100644 tests/generic/1224 create mode 100644 tests/generic/1224.out create mode 100644 tests/generic/1225 create mode 100644 tests/generic/1225.out create mode 100755 tests/xfs/1216 create mode 100644 tests/xfs/1216.out create mode 100755 tests/xfs/1217 create mode 100644 tests/xfs/1217.out create mode 100644 tests/xfs/1218 create mode 100644 tests/xfs/1218.out
common/atomicwrites +10 -0
@@ -115,3 +115,13 @@ _test_atomic_file_writes() $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" } + +_simple_atomic_write() { + local pos=$1 + local count=$2 + local file=$3 + local directio=$4 + + echo "testing pos=$pos count=$count file=$file directio=$directio" >> $seqres.full + $XFS_IO_PROG $directio -c "pwrite -b $count -V 1 -A -D $pos $count" $file >> $seqres.full +}
tests/generic/1222 new file +86 -0
86 lines not on this page · raw message
tests/generic/1222.out new file +10 -0
@@ -0,0 +1,10 @@ +QA output created by 1222 +two EINVAL for unsupported sizes +pwrite: Invalid argument +pwrite: Invalid argument +all should work +one EOPNOTSUPP for buffered atomic +pwrite: Operation not supported +one EINVAL for unaligned directio +pwrite: Invalid argument +Silence is golden
tests/generic/1223 new file +66 -0
66 lines not on this page · raw message
tests/generic/1223.out new file +9 -0
@@ -0,0 +1,9 @@ +QA output created by 1223 +two EINVAL for unsupported sizes +pwrite: Invalid argument +pwrite: Invalid argument +one EOPNOTSUPP for buffered atomic +pwrite: Operation not supported +one EINVAL for unaligned directio +pwrite: Invalid argument +Silence is golden
tests/generic/1224 new file +140 -0
140 lines not on this page · raw message
tests/generic/1224.out new file +17 -0
@@ -0,0 +1,17 @@ +QA output created by 1224 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +4edfbc469bed9965219ea80c9ae54626 SCRATCH_MNT/file1 +93243a293a9f568903485b0b2a895815 SCRATCH_MNT/file2 +9464b66461bc1d20229e1b71733539d0 SCRATCH_MNT/file1 +9464b66461bc1d20229e1b71733539d0 SCRATCH_MNT/file1 +9464b66461bc1d20229e1b71733539d0 SCRATCH_MNT/file1 +75572c4929fde8faf131e84df4c6a764 SCRATCH_MNT/file1 +27a248351cd540bc9ac2c2dc841abca2 SCRATCH_MNT/file1 +27c9068d1b51da575a53ad34c57ca5cc SCRATCH_MNT/file3
tests/generic/1225 new file +51 -0
51 lines not on this page · raw message
tests/generic/1225.out new file +1 -0
@@ -0,0 +1 @@ +QA output created by 1225
tests/xfs/1216 new file +68 -0
68 lines not on this page · raw message
tests/xfs/1216.out new file +9 -0
@@ -0,0 +1,9 @@ +QA output created by 1216 +two EINVAL for unsupported sizes +pwrite: Invalid argument +pwrite: Invalid argument +one EOPNOTSUPP for buffered atomic +pwrite: Operation not supported +one EINVAL for unaligned directio +pwrite: Invalid argument +Silence is golden
tests/xfs/1217 new file +70 -0
70 lines not on this page · raw message
tests/xfs/1217.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 1217 +pwrite: Input/output error +touch: cannot touch 'SCRATCH_MNT/barf': Input/output error
tests/xfs/1218 new file +59 -0
59 lines not on this page · raw message
tests/xfs/1218.out new file +15 -0
@@ -0,0 +1,15 @@ +QA output created by 1218 +Create files +Check files +77e3a730e3c75274c9ce310d7e39f938 SCRATCH_MNT/file1 +77e3a730e3c75274c9ce310d7e39f938 SCRATCH_MNT/file2 +Inject error +Atomic write to a reflinked file +pwrite: Input/output error +FS should be shut down, touch will fail +touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error +Remount to replay log +Check files +0df1f61ed02a7e9bee2b8b7665066ddc SCRATCH_MNT/file1 +77e3a730e3c75274c9ce310d7e39f938 SCRATCH_MNT/file2 +FS should be online, touch should succeed
Signature · 1 line
2.34.1
Re: [PATCH 6/6] generic: various atomic write tests with scsi_debug
Quoted 71 lines
+++ b/tests/generic/1222
tests/generic/1222 new file +68
-0@@ -0,0 +1,86 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1222 +# +# Validate multi-fsblock atomic write support with simulated hardware support +# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/scsi_debug +. ./common/atomicwrites + +_cleanup() +{ + _scratch_unmount &>/dev/null + _put_scsi_debug_dev &>/dev/null + cd / + rm -r -f $tmp.* +} + +_require_scsi_debug +_require_scratch_nocheck +# Format something so that ./check doesn't freak out +_scratch_mkfs >> $seqres.full + +# 512b logical/physical sectors, 512M size, atomic writes enabled +dev=$(_get_scsi_debug_dev 512 512 0 512 "atomic_wr=1") +test -b "$dev" || _notrun "could not create atomic writes scsi_debug device" + +export SCRATCH_DEV=$dev +unset USE_EXTERNAL + +_require_scratch_write_atomic +_require_atomic_write_test_commands + +echo "scsi_debug atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_DEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev data $SCRATCH_MNT + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +echo "filesystem atomic write properties" >> $seqres.full +$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) + +$XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile + +# try outside the advertised sizes +echo "two EINVAL for unsupported sizes" +min_i=$((min_awu / 2)) +_simple_atomic_write $min_i $min_i $testfile -d +max_i=$((max_awu * 2)) +_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 + _test_atomic_file_writes $i $testfile
tests/generic/1222 line 78
Quoted 10 lines
tests/generic/1222 new file +10
-0+ _simple_atomic_write $i $i $testfile -d +done + +# does not support buffered io +echo "one EOPNOTSUPP for buffered atomic" +_simple_atomic_write 0 $min_awu $testfile + +# does not support unaligned directio +echo "one EINVAL for unaligned directio" +_simple_atomic_write $sector_size $min_awu $testfile -d
I figure that $sector_size is default at 512, which would never be equal to fsblocksize (so the test looks ok)
Quoted 55 lines
tests/generic/1222 new file +8
-0+ +_scratch_unmount +_put_scsi_debug_dev + +# success, all done +echo Silence is golden +status=0 +exittests/generic/1222.out new file +10
-0@@ -0,0 +1,10 @@ +QA output created by 1222 +two EINVAL for unsupported sizes +pwrite: Invalid argument +pwrite: Invalid argument +all should work +one EOPNOTSUPP for buffered atomic +pwrite: Operation not supported +one EINVAL for unaligned directio +pwrite: Invalid argument +Silence is goldentests/generic/1223 new file +25
-0@@ -0,0 +1,66 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1223 +# +# Validate multi-fsblock atomic write support with or without hw support +# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites + +_require_scratch +_require_atomic_write_test_commands + +echo "scratch device atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_DEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev data $SCRATCH_MNT + +testfile=$SCRATCH_MNT/testfile +touch $testfile
tests/generic/1223 line 35
Quoted 10 lines
tests/generic/1223 new file +10
-0+ +echo "filesystem atomic write properties" >> $seqres.full +$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) + +$XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile +
It seems many sub-tests are same as 1222
It is difficult to factor them out?
Quoted 178 lines
tests/generic/1223 new file +31
-0+# try outside the advertised sizes +echo "two EINVAL for unsupported sizes" +min_i=$((min_awu / 2)) +_simple_atomic_write $min_i $min_i $testfile -d +max_i=$((max_awu * 2)) +_simple_atomic_write $max_i $max_i $testfile -d + +# try all of the advertised sizes +for ((i = min_awu; i <= max_awu; i *= 2)); do + $XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile + _test_atomic_file_writes $i $testfile + _simple_atomic_write $i $i $testfile -d +done + +# does not support buffered io +echo "one EOPNOTSUPP for buffered atomic" +_simple_atomic_write 0 $min_awu $testfile + +# does not support unaligned directio +echo "one EINVAL for unaligned directio" +if [ $sector_size -lt $min_awu ]; then + _simple_atomic_write $sector_size $min_awu $testfile -d +else + # not supported, so fake the output + echo "pwrite: Invalid argument" +fi + +# success, all done +echo Silence is golden +status=0 +exittests/generic/1223.out new file +9
-0@@ -0,0 +1,9 @@ +QA output created by 1223 +two EINVAL for unsupported sizes +pwrite: Invalid argument +pwrite: Invalid argument +one EOPNOTSUPP for buffered atomic +pwrite: Operation not supported +one EINVAL for unaligned directio +pwrite: Invalid argument +Silence is goldentests/generic/1224 new file +126
-0@@ -0,0 +1,140 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1224 +# +# test large atomic writes with mixed mappings +# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites +. ./common/filter +. ./common/reflink + +_require_scratch +_require_atomic_write_test_commands +_require_xfs_io_command pwrite -A +_require_cp_reflink + +_scratch_mkfs_sized $((500 * 1048576)) >> $seqres.full 2>&1 +_scratch_mount + +file1=$SCRATCH_MNT/file1 +file2=$SCRATCH_MNT/file2 +file3=$SCRATCH_MNT/file3 + +touch $file1 + +max_awu=$(_get_atomic_write_unit_max $file1) +test $max_awu -ge 262144 || _notrun "test requires atomic writes up to 256k" + +min_awu=$(_get_atomic_write_unit_min $file1) +test $min_awu -le 4096 || _notrun "test requires atomic writes down to 4k" + +bsize=$(_get_file_block_size $SCRATCH_MNT) +test $max_awu -gt $((bsize * 2)) || \ + _notrun "max atomic write $max_awu less than 2 fsblocks $bsize" + +# reflink tests (files with shared extents) + +# atomic write shared data and unshared+shared data +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +cp --reflink=always $file1 $file2 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 32768" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch +md5sum $file2 | _filter_scratch + +# atomic write shared data and shared+unshared data +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +cp --reflink=always $file1 $file2 +$XFS_IO_PROG -dc "pwrite -A -D -V1 32768 32768" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch +md5sum $file2 | _filter_scratch + +# atomic overwrite unshared data +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +cp --reflink=always $file1 $file2 +$XFS_IO_PROG -dc "pwrite -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch +md5sum $file2 | _filter_scratch + +# atomic write shared+unshared+shared data +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +cp --reflink=always $file1 $file2 +$XFS_IO_PROG -dc "pwrite -D -V1 4096 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch +md5sum $file2 | _filter_scratch + +# atomic write interweaved hole+unwritten+written+reflinked +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +blksz=4096 +nr=32 +_weave_reflink_rainbow $blksz $nr $file1 $file2 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch +md5sum $file2 | _filter_scratch + +# non-reflink tests + +# atomic write hole+mapped+hole +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 4096000 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 4096 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch + +# atomic write adjacent mapped+hole and hole+mapped +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 4096000 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 0 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 61440 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 32768" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 32768 32768" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch + +# atomic write mapped+hole+mapped +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 4096000 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 0 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -D -V1 61440 4096" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch + +# atomic write at EOF +dd if=/dev/zero of=$file1 bs=128K count=3 conv=fsync >>$seqres.full 2>&1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 262144 262144" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch + +# atomic write preallocated region +fallocate -l 10M $file1 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file1 >>$seqres.full 2>&1 +md5sum $file1 | _filter_scratch + +# atomic write max size +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +aw_max=$(_get_atomic_write_unit_max $file1) +cp $file1 $file1.chk +$XFS_IO_PROG -dc "pwrite -D -V1 0 $aw_max" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -c "pwrite 0 $aw_max" $file1.chk >>$seqres.full 2>&1 +cmp -s $file1 $file1.chk || echo "file1 doesnt match file1.chk" +#md5sum $file1 | _filter_scratch
tests/generic/1224 line 136
Quoted 10 lines
tests/generic/1224 new file +10
-0+ +# atomic write max size on fragmented fs +avail=`_get_available_space $SCRATCH_MNT` +filesizemb=$((avail / 1024 / 1024 - 1)) +fragmentedfile=$SCRATCH_MNT/fragmentedfile +$XFS_IO_PROG -fc "falloc 0 ${filesizemb}m" $fragmentedfile +$here/src/punch-alternating $fragmentedfile +touch $file3 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file3 >>$seqres.full 2>&1 +md5sum $file3 | _filter_scratch
nice :)
But we also test RWF_NOWAIT at some stage?
RWF_NOWAIT should fail always for filesystem-based atomic write
tests/generic/1225
Quoted 32 lines
tests/generic/1224 new file +4
-0+ +# success, all done +status=0 +exittests/generic/1224.out new file +17
-0@@ -0,0 +1,17 @@ +QA output created by 1224 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +111ce6bf29d5b1dbfb0e846c42719ece SCRATCH_MNT/file1 +f1c9645dbc14efddc7d8a322685f26eb SCRATCH_MNT/file2 +4edfbc469bed9965219ea80c9ae54626 SCRATCH_MNT/file1 +93243a293a9f568903485b0b2a895815 SCRATCH_MNT/file2 +9464b66461bc1d20229e1b71733539d0 SCRATCH_MNT/file1 +9464b66461bc1d20229e1b71733539d0 SCRATCH_MNT/file1 +9464b66461bc1d20229e1b71733539d0 SCRATCH_MNT/file1 +75572c4929fde8faf131e84df4c6a764 SCRATCH_MNT/file1 +27a248351cd540bc9ac2c2dc841abca2 SCRATCH_MNT/file1 +27c9068d1b51da575a53ad34c57ca5cc SCRATCH_MNT/file3tests/generic/1225 new file +0
-0
I think that we should now omit this test. We don't guarantee serialization of atomic writes, so no point in testing it.
I should have confirmed this earlier, sorry
Quoted 65 lines
tests/generic/1225 new file +51
-0@@ -0,0 +1,51 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1215 +# +# fio test for large atomic writes +# +. ./common/preamble +_begin_fstest aio rw stress atomicwrites + +. ./common/atomicwrites + +fio_config=$tmp.fio + +_require_scratch +_require_atomic_write_test_commands +_require_aio +_require_odirect + +cat >$fio_config <<EOF +[iops-test] +directory=${SCRATCH_MNT} +filesize=1M +filename=testfile +rw=write +bs=16k +ioengine=libaio +loops=1000 +numjobs=10 +iodepth=1024 +group_reporting=1 +direct=1 +verify=crc64 +verify_write_sequence=0 +exitall_on_error=1 +atomic=1 +EOF + +_require_fio $fio_config + +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +echo "Run fio with large atomic writes" +cat $fio_config >> $seqres.full +run_check $FIO_PROG $fio_config + +# success, all done +status=0 +exittests/generic/1225.out new file +1
-0@@ -0,0 +1 @@ +QA output created by 1225tests/xfs/1216 new file +0
-0
tests/xfs/1216 line 8
Quoted 8 lines
tests/xfs/1216 new file +8
-0@@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1216 +# +# Validate multi-fsblock realtime file atomic write support with or without hw +# support
nice to see rtvol being tested.
Quoted 81 lines
tests/xfs/1216 new file +60
-0+# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites + +_require_realtime +_require_scratch +_require_atomic_write_test_commands + +echo "scratch device atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_RTDEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev realtime $SCRATCH_MNT + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +echo "filesystem atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $testfile >> $seqres.full + +sector_size=$(blockdev --getss $SCRATCH_RTDEV) +min_awu=$(_get_atomic_write_unit_min $testfile) +max_awu=$(_get_atomic_write_unit_max $testfile) + +$XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile + +# try outside the advertised sizes +echo "two EINVAL for unsupported sizes" +min_i=$((min_awu / 2)) +_simple_atomic_write $min_i $min_i $testfile -d +max_i=$((max_awu * 2)) +_simple_atomic_write $max_i $max_i $testfile -d + +# try all of the advertised sizes +for ((i = min_awu; i <= max_awu; i *= 2)); do + $XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile + _test_atomic_file_writes $i $testfile + _simple_atomic_write $i $i $testfile -d +done + +# does not support buffered io +echo "one EOPNOTSUPP for buffered atomic" +_simple_atomic_write 0 $min_awu $testfile + +# does not support unaligned directio +echo "one EINVAL for unaligned directio" +if [ $sector_size -lt $min_awu ]; then + _simple_atomic_write $sector_size $min_awu $testfile -d +else + # not supported, so fake the output + echo "pwrite: Invalid argument" +fi + +# success, all done +echo Silence is golden +status=0 +exittests/xfs/1216.out new file +9
-0@@ -0,0 +1,9 @@ +QA output created by 1216 +two EINVAL for unsupported sizes +pwrite: Invalid argument +pwrite: Invalid argument +one EOPNOTSUPP for buffered atomic +pwrite: Operation not supported +one EINVAL for unaligned directio +pwrite: Invalid argument +Silence is goldentests/xfs/1217 new file +0
-0
tests/xfs/1217 line 8
Quoted 8 lines
tests/xfs/1217 new file +8
-0@@ -0,0 +1,70 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1217 +# +# Check that software atomic writes can complete an operation after a crash. +#
Could we prove that we get a torn write for a regular non-atomic write also?
tests/xfs/1217 line 11
Quoted 3 lines
tests/xfs/1217 new file +3
-0+. ./common/preamble +_begin_fstest auto quick rw atomicwrites +
Thanks,
John
Re: [PATCH 6/6] generic: various atomic write tests with scsi_debug
Quoted 3 lines · John Garry
Quoted 3 lines
+++ b/tests/generic/1222
(quoted diff) +0
-0@@ -0,0 +1,86 @@
<snip>
Quoted 10 lines
Quoted 10 lines
tests/generic/1222 new file +10
-0+# 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 + _test_atomic_file_writes $i $testfile + _simple_atomic_write $i $i $testfile -d +done + +# does not support buffered io +echo "one EOPNOTSUPP for buffered atomic"
Quoted 8 lines
tests/generic/1222 line 78
Quoted 5 lines
tests/generic/1222 new file +5
-0+_simple_atomic_write 0 $min_awu $testfile + +# does not support unaligned directio +echo "one EINVAL for unaligned directio" +_simple_atomic_write $sector_size $min_awu $testfile -dI figure that $sector_size is default at 512, which would never be equal to fsblocksize (so the test looks ok)
For now, yes -- the only filesystems supporting atomic writes (ext4 and XFS v5) don't support 512b fsblocks.
<snip>
Quoted 44 lines
Quoted 31 lines
tests/generic/1223 new file +25
-0@@ -0,0 +1,66 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1223 +# +# Validate multi-fsblock atomic write support with or without hw support +# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites + +_require_scratch +_require_atomic_write_test_commands + +echo "scratch device atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_DEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev data $SCRATCH_MNT + +testfile=$SCRATCH_MNT/testfile +touch $testfiletests/generic/1223 line 35
Quoted 10 lines
tests/generic/1223 new file +10
-0+ +echo "filesystem atomic write properties" >> $seqres.full +$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) + +$XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile +It seems many sub-tests are same as 1222
Quoted 1 line
It is difficult to factor them out?
Yes. g/1222 will _notrun itself if the scsi_debug module isn't present or the fake device cannot be created. Apparently many of the people who run fstests also have test infrastructure that cannot handle modules, so they don't run anything involving scsi_debug.
That's why g/1223 only requires that the scratch fs advertises some sort of atomic write capability, it doesn't care how it provides that.
<snip>
Quoted 5 lines
Quoted 5 lines
tests/generic/1224 new file +0
-0
<snip>
Quoted 21 lines
Quoted 8 lines
tests/generic/1224 new file +8
-0+# atomic write max size +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +aw_max=$(_get_atomic_write_unit_max $file1) +cp $file1 $file1.chk +$XFS_IO_PROG -dc "pwrite -D -V1 0 $aw_max" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -c "pwrite 0 $aw_max" $file1.chk >>$seqres.full 2>&1 +cmp -s $file1 $file1.chk || echo "file1 doesnt match file1.chk" +#md5sum $file1 | _filter_scratchtests/generic/1224 line 136
Quoted 10 lines
tests/generic/1224 new file +10
-0+ +# atomic write max size on fragmented fs +avail=`_get_available_space $SCRATCH_MNT` +filesizemb=$((avail / 1024 / 1024 - 1)) +fragmentedfile=$SCRATCH_MNT/fragmentedfile +$XFS_IO_PROG -fc "falloc 0 ${filesizemb}m" $fragmentedfile +$here/src/punch-alternating $fragmentedfile +touch $file3 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file3 >>$seqres.full 2>&1 +md5sum $file3 | _filter_scratchnice :)
Quoted 3 lines
But we also test
RWF_NOWAITat some stage?
RWF_NOWAITshould fail always for filesystem-based atomic write
It's hard to test NOWAIT because the selected io path might not actually encounter contention, and there are various things that NOWAIT will wait on anyway (like memory allocation and metadata reads).
<snip>
Quoted 10 lines
tests/generic/1225
Quoted 5 lines
tests/generic/1225 new file +0
-0I think that we should now omit this test. We don't guarantee serialization of atomic writes, so no point in testing it.
I should have confirmed this earlier, sorry
Ok.
<snip>
Quoted 8 lines
Quoted 8 lines
tests/xfs/1216 new file +2
-0@@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0
Quoted 8 lines
tests/xfs/1216 line 8
Quoted 6 lines
tests/xfs/1216 new file +6
-0+# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1216 +# +# Validate multi-fsblock realtime file atomic write support with or without hw +# supportnice to see rtvol being tested.
Thanks. :)
Quoted 8 lines
Quoted 8 lines
tests/xfs/1216 new file +8
-0+# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites + +_require_realtime +_require_scratch
Quoted 8 lines
tests/xfs/1216 line 24
Quoted 8 lines
tests/xfs/1216 new file +8
-0+_require_atomic_write_test_commands + +echo "scratch device atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_RTDEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev realtime $SCRATCH_MNT
Don't need this FSTYP test here, FSTYP is always xfs.
<snip>
Quoted 8 lines
Quoted 8 lines
tests/xfs/1217 new file +2
-0@@ -0,0 +1,70 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0
Quoted 8 lines
tests/xfs/1217 line 8
Quoted 6 lines
tests/xfs/1217 new file +6
-0+# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1217 +# +# Check that software atomic writes can complete an operation after a crash. +#Could we prove that we get a torn write for a regular non-atomic write also?
Perhaps? But I don't see the point -- non-atomic write completions could be done atomically.
--D
Quoted 7 lines
tests/xfs/1217 line 11
Quoted 3 lines
tests/xfs/1217 new file +3
-0+. ./common/preamble +_begin_fstest auto quick rw atomicwrites +Thanks,
John
Re: [PATCH 6/6] generic: various atomic write tests with scsi_debug
Quoted 7 lines · Darrick J. Wong
Quoted 3 lines
It seems many sub-tests are same as 1222
It is difficult to factor them out?
Yes. g/1222 will
_notrunitself if thescsi_debugmodule isn't present or the fake device cannot be created. Apparently many of the people who run fstests also have test infrastructure that cannot handle modules, so they don't run anything involvingscsi_debug.
ok...
Quoted 15 lines
That's why g/1223 only requires that the scratch fs advertises some sort of atomic write capability, it doesn't care how it provides that.
<snip>
Quoted 5 lines
Quoted 5 lines
tests/generic/1224 new file +0
-0<snip>
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
But we also test
RWF_NOWAITat some stage?
RWF_NOWAITshould fail always for filesystem-based atomic writeIt's hard to test NOWAIT because the selected io path might not actually encounter contention, and there are various things that NOWAIT will wait on anyway (like memory allocation and metadata reads).
The filesystem-based atomic write will always try to allocate blocks, and this will fail for NOWAIT.
But, come to think of it, this is not even a useful test - so forget the suggestion. I was just testing this as a sanity check to prove that we are getting expected behavior.
Quoted 19 lines
<snip>
Quoted 7 lines
Quoted 7 lines
tests/xfs/1217 new file +1
-0@@ -0,0 +1,70 @@ +#! /bin/bashQuoted 8 lines
tests/xfs/1217 line 8
Quoted 7 lines
tests/xfs/1217 new file +7
-0+# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1217 +# +# Check that software atomic writes can complete an operation after a crash. +#Could we prove that we get a torn write for a regular non-atomic write also?
Quoted 2 lines
Perhaps? But I don't see the point -- non-atomic write completions could be done atomically.
oh, from my reading of the test, I thought that we were ensuring that we are writing over many extents, and so could not be completed atomically for a non-atomic write.
BTW, there is a typo in a comment for that test, please see "ssecond block"
Thanks,
John
Re: [PATCH 6/6] generic: various atomic write tests with scsi_debug
In reply to Darrick J. WongQuoted 138 lines · Darrick J. Wong
Quoted 3 lines · John Garry
Quoted 3 lines
+++ b/tests/generic/1222
(quoted diff) +0
-0@@ -0,0 +1,86 @@<snip>
Quoted 10 lines
Quoted 10 lines
tests/generic/1222 new file +10
-0+# 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 + _test_atomic_file_writes $i $testfile + _simple_atomic_write $i $i $testfile -d +done + +# does not support buffered io +echo "one EOPNOTSUPP for buffered atomic"Quoted 8 lines
tests/generic/1222 line 78
Quoted 5 lines
tests/generic/1222 new file +5
-0+_simple_atomic_write 0 $min_awu $testfile + +# does not support unaligned directio +echo "one EINVAL for unaligned directio" +_simple_atomic_write $sector_size $min_awu $testfile -dI figure that $sector_size is default at 512, which would never be equal to fsblocksize (so the test looks ok)
For now, yes -- the only filesystems supporting atomic writes (ext4 and XFS v5) don't support 512b fsblocks.
<snip>
Quoted 44 lines
Quoted 31 lines
tests/generic/1223 new file +25
-0@@ -0,0 +1,66 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1223 +# +# Validate multi-fsblock atomic write support with or without hw support +# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites + +_require_scratch +_require_atomic_write_test_commands + +echo "scratch device atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_DEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev data $SCRATCH_MNT + +testfile=$SCRATCH_MNT/testfile +touch $testfiletests/generic/1223 line 35
Quoted 10 lines
tests/generic/1223 new file +10
-0+ +echo "filesystem atomic write properties" >> $seqres.full +$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) + +$XFS_IO_PROG -f -c "falloc 0 $((max_awu * 2))" -c fsync $testfile +It seems many sub-tests are same as 1222
Quoted 1 line
It is difficult to factor them out?
Yes. g/1222 will
_notrunitself if thescsi_debugmodule isn't present or the fake device cannot be created. Apparently many of the people who run fstests also have test infrastructure that cannot handle modules, so they don't run anything involvingscsi_debug.That's why g/1223 only requires that the scratch fs advertises some sort of atomic write capability, it doesn't care how it provides that.
<snip>
Quoted 5 lines
Quoted 5 lines
tests/generic/1224 new file +0
-0<snip>
Quoted 21 lines
Quoted 8 lines
tests/generic/1224 new file +8
-0+# atomic write max size +dd if=/dev/zero of=$file1 bs=1M count=10 conv=fsync >>$seqres.full 2>&1 +aw_max=$(_get_atomic_write_unit_max $file1) +cp $file1 $file1.chk +$XFS_IO_PROG -dc "pwrite -D -V1 0 $aw_max" $file1 >>$seqres.full 2>&1 +$XFS_IO_PROG -c "pwrite 0 $aw_max" $file1.chk >>$seqres.full 2>&1 +cmp -s $file1 $file1.chk || echo "file1 doesnt match file1.chk" +#md5sum $file1 | _filter_scratchtests/generic/1224 line 136
Quoted 10 lines
tests/generic/1224 new file +10
-0+ +# atomic write max size on fragmented fs +avail=`_get_available_space $SCRATCH_MNT` +filesizemb=$((avail / 1024 / 1024 - 1)) +fragmentedfile=$SCRATCH_MNT/fragmentedfile +$XFS_IO_PROG -fc "falloc 0 ${filesizemb}m" $fragmentedfile +$here/src/punch-alternating $fragmentedfile +touch $file3 +$XFS_IO_PROG -dc "pwrite -A -D -V1 0 65536" $file3 >>$seqres.full 2>&1 +md5sum $file3 | _filter_scratchnice :)
Quoted 3 lines
But we also test
RWF_NOWAITat some stage?
RWF_NOWAITshould fail always for filesystem-based atomic writeIt's hard to test NOWAIT because the selected io path might not actually encounter contention, and there are various things that NOWAIT will wait on anyway (like memory allocation and metadata reads).
<snip>
Quoted 9 lines
tests/generic/1225
Quoted 5 lines
tests/generic/1225 new file +0
-0I think that we should now omit this test. We don't guarantee serialization of atomic writes, so no point in testing it.
Quoted 5 lines
Quoted 1 line
I should have confirmed this earlier, sorry
Ok.
<snip>
Ok, I’ll remove this test
Quoted 39 lines
Quoted 17 lines
Quoted 7 lines
tests/xfs/1216 new file +0
-0tests/xfs/1216 line 8
Quoted 8 lines
tests/xfs/1216 new file +8
-0@@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1216 +# +# Validate multi-fsblock realtime file atomic write support with or without hw +# supportnice to see rtvol being tested.
Thanks. :)
Quoted 8 lines
Quoted 8 lines
tests/xfs/1216 new file +8
-0+# +. ./common/preamble +_begin_fstest auto quick rw atomicwrites + +. ./common/atomicwrites + +_require_realtime +_require_scratchQuoted 8 lines
tests/xfs/1216 line 24
Quoted 8 lines
tests/xfs/1216 new file +8
-0+_require_atomic_write_test_commands + +echo "scratch device atomic write properties" >> $seqres.full +$XFS_IO_PROG -c "statx -r -m $STATX_WRITE_ATOMIC" $SCRATCH_RTDEV >> $seqres.full + +_scratch_mkfs >> $seqres.full +_scratch_mount +test "$FSTYP" = "xfs" && _xfs_force_bdev realtime $SCRATCH_MNTDon't need this FSTYP test here, FSTYP is always xfs.
Quoted 1 line
<snip>
Ok, will remove this as well, thanks!
Quoted 29 lines
Quoted 17 lines
Quoted 7 lines
tests/xfs/1217 new file +0
-0tests/xfs/1217 line 8
Quoted 8 lines
tests/xfs/1217 new file +8
-0@@ -0,0 +1,70 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle. All Rights Reserved. +# +# FS QA Test 1217 +# +# Check that software atomic writes can complete an operation after a crash. +#Could we prove that we get a torn write for a regular non-atomic write also?
Perhaps? But I don't see the point -- non-atomic write completions could be done atomically.
--D
Quoted 6 lines
tests/xfs/1217 line 11
Quoted 3 lines
tests/xfs/1217 new file +3
-0+. ./common/preamble +_begin_fstest auto quick rw atomicwrites +Thanks,
John