fstests: catch us up to 6.10
Hi everyone,
This patchbomb are all the fixes that xfs needs to bring fstests up to date with what's in 6.10-rc. Except for these two patches:
[PATCHSET v30.7 2/6] fstests: atomic file updates [PATCH 03/11] generic/709,710: rework these for exchangerange vs. [PATCH 04/11] generic/711,xfs/537: actually fork these tests for
everything else in here is fully reviewed and ready for PRs.
--D
PATCH 1/6 xfsprogs: scale shards on ssds
Hi all,
For a long time, the maintainers have had a gut feeling that we could optimize performance of XFS filesystems on non-mechanical storage by scaling the number of allocation groups to be a multiple of the CPU count.
With modern ~2022 hardware, it is common for systems to have more than four CPU cores and non-striped SSDs ranging in size from 256GB to 4TB. The default mkfs geometry still defaults to 4 AGs regardless of core count, which was settled on in the age of spinning rust.
This patchset adds a different computation for AG count and log size that is based entirely on a desired level of concurrency. If we detect storage that is non-rotational (or the sysadmin provides a CLI option), then we will try to match the AG count to the CPU count to minimize AGF contention and make the log large enough to minimize grant head contention.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=mkfs-scale-geo-on-ssds
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=mkfs-scale-geo-on-ssds
---
Commits in this patchset:
* xfs: test scaling of the mkfs concurrency options
--- tests/xfs/1842 | 55 ++++++++++++++ tests/xfs/1842.cfg | 4 + tests/xfs/1842.out.lba1024 | 177 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1842.out.lba2048 | 177 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1842.out.lba4096 | 177 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1842.out.lba512 | 177 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 767 insertions(+) create mode 100755 tests/xfs/1842 create mode 100644 tests/xfs/1842.cfg create mode 100644 tests/xfs/1842.out.lba1024 create mode 100644 tests/xfs/1842.out.lba2048 create mode 100644 tests/xfs/1842.out.lba4096 create mode 100644 tests/xfs/1842.out.lba512
PATCH 1/1 xfs: test scaling of the mkfs concurrency options
From: Darrick J. Wong <[email protected]>
Make sure that the AG count and log size scale up with the new concurrency options to mkfs.
--- tests/xfs/1842 | 55 ++++++++++++++ tests/xfs/1842.cfg | 4 + tests/xfs/1842.out.lba1024 | 177 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1842.out.lba2048 | 177 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1842.out.lba4096 | 177 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1842.out.lba512 | 177 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 767 insertions(+) create mode 100755 tests/xfs/1842 create mode 100644 tests/xfs/1842.cfg create mode 100644 tests/xfs/1842.out.lba1024 create mode 100644 tests/xfs/1842.out.lba2048 create mode 100644 tests/xfs/1842.out.lba4096 create mode 100644 tests/xfs/1842.out.lba512
tests/xfs/1842 new file +55 -0
@@ -0,0 +1,55 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1842 +# +# mkfs concurrency test - ensure the log and agsize scaling works for various +# concurrency= parameters +# +. ./common/preamble +_begin_fstest log metadata auto quick + +# Import common functions. +. ./common/filter +. ./common/reflink + +_cleanup() +{ + cd / + rm -r -f $tmp.* $loop_file +} + +# real QA test starts here +_supported_fs xfs + +_require_test +_require_loop +$MKFS_XFS_PROG 2>&1 | grep -q concurrency || \ + _notrun "mkfs does not support concurrency options" + +test_dev_lbasize=$(blockdev --getss $TEST_DEV) +seqfull=$0 +_link_out_file "lba${test_dev_lbasize}" + +loop_file=$TEST_DIR/$seq.loop + +rm -f "$loop_file" +for sz in 16M 512M 1G 2G 16G 64G 256G 512G 1T 2T 4T 16T 64T 256T 512T 1P; do + for cpus in 2 4 8 16 32 40 64 96 160 512; do + truncate -s "$sz" "$loop_file" + echo "sz $sz cpus $cpus" >> $seqres.full + echo "-----------------" >> $seqres.full + + $MKFS_XFS_PROG -f -N "$loop_file" -d concurrency=$cpus -l concurrency=$cpus &> $tmp.mkfsout + cat $tmp.mkfsout >> $seqres.full + + _filter_mkfs > /dev/null 2> $tmp.mkfs < $tmp.mkfsout + . $tmp.mkfs + echo "sz $sz cpus $cpus agcount $agcount logblocks $lblocks" + done + echo "-----------------" +done + +status=0 +exit
tests/xfs/1842.cfg new file +4 -0
@@ -0,0 +1,4 @@ +lba512: lba512 +lba1024: lba1024 +lba2048: lba2048 +lba4096: lba4096
tests/xfs/1842.out.lba1024 new file +177 -0
177 lines not on this page · raw message
tests/xfs/1842.out.lba2048 new file +177 -0
177 lines not on this page · raw message
tests/xfs/1842.out.lba4096 new file +177 -0
177 lines not on this page · raw message
tests/xfs/1842.out.lba512 new file +177 -0
177 lines not on this page · raw message
PATCH 2/6 fstests: atomic file updates
In reply to Darrick J. WongHi all,
This series creates a new XFS_IOC_EXCHANGE_RANGE ioctl to exchange ranges of bytes between two files atomically.
This new functionality enables data storage programs to stage and commit file updates such that reader programs will see either the old contents or the new contents in their entirety, with no chance of torn writes. A successful call completion guarantees that the new contents will be seen even if the system fails.
The ability to exchange file fork mappings between files in this manner is critical to supporting online filesystem repair, which is built upon the strategy of constructing a clean copy of a damaged structure and committing the new structure into the metadata file atomically. The ioctls exist to facilitate testing of the new functionality and to enable future application program designs.
User programs will be able to update files atomically by opening an O_TMPFILE, reflinking the source file to it, making whatever updates they want to make, and exchange the relevant ranges of the temp file with the original file. If the updates are aligned with the file block size, a new (since v2) flag provides for exchanging only the written areas. Note that application software must quiesce writes to the file while it stages an atomic update. This will be addressed by a subsequent series.
This mechanism solves the clunkiness of two existing atomic file update
mechanisms: for O_TRUNC + rewrite, this eliminates the brief period where other programs can see an empty file. For create tempfile + rename, the need to copy file attributes and extended attributes for each file update is eliminated.
However, this method introduces its own awkwardness -- any program initiating an exchange now needs to have a way to signal to other programs that the file contents have changed. For file access mediated via read and write, fanotify or inotify are probably sufficient. For mmaped files, that may not be fast enough.
The reference implementation in XFS creates a new log incompat feature and log intent items to track high level progress of swapping ranges of two files and finish interrupted work if the system goes down. Sample code can be found in the corresponding changes to xfs_io to exercise the use case mentioned above.
Note that this function is /not/ the O_DIRECT atomic untorn file writes concept that has also been floating around for years. It is also not the RWF_ATOMIC patchset that has been shared. This RFC is constructed entirely in software, which means that there are no limitations other than the general filesystem limits.
As a side note, the original motivation behind the kernel functionality is online repair of file-based metadata. The atomic file content exchange is implemented as an atomic exchange of file fork mappings, which means that we can implement online reconstruction of extended attributes and directories by building a new one in another inode and exchanging the contents.
Subsequent patchsets adapt the online filesystem repair code to use atomic file exchanges. This enables repair functions to construct a clean copy of a directory, xattr information, symbolic links, realtime bitmaps, and realtime summary information in a temporary inode. If this completes successfully, the new contents can be committed atomically into the inode being repaired. This is essential to avoid making corruption problems worse if the system goes down in the middle of running repair.
For userspace, this series also includes the userspace pieces needed to test the new functionality, and a sample implementation of atomic file updates.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=atomic-file-updates
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=atomic-file-updates
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=atomic-file-updates
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=atomic-file-updates
---
Commits in this patchset:
* misc: split swapext and exchangerange
* misc: change xfs_io -c swapext to exchangerange
* generic/709,710: rework these for exchangerange vs. quota testing
* generic/711,xfs/537: actually fork these tests for exchange-range
* generic/717: remove obsolete check
* ltp/{fsstress,fsx}: make the exchangerange naming consistent
* misc: flip HAVE_XFS_IOC_EXCHANGE_RANGE logic
* src/fiexchange.h: update XFS_IOC_EXCHANGE_RANGE definitions
* xfs/122: fix for exchrange conversion
* xfs/206: screen out exchange-range from golden output
* exchangerange: make sure that we don't swap unwritten extents unless they're part of a rt extent
--- common/rc | 2 common/xfs | 2 configure.ac | 2 include/builddefs.in | 2 ltp/Makefile | 4 - ltp/fsstress.c | 34 +++---- ltp/fsx.c | 43 +++------ m4/package_xfslibs.m4 | 15 ++- src/Makefile | 4 - src/fiexchange.h | 84 ++++------------- src/global.h | 12 ++ src/vfs/Makefile | 4 - src/xfsfind.c | 1 tests/generic/1221 | 45 +++++++++ tests/generic/1221.out | 2 tests/generic/709 | 12 +- tests/generic/710 | 14 +-- tests/generic/710.out | 2 tests/generic/711 | 4 - tests/generic/712 | 10 +- tests/generic/713 | 42 ++++----- tests/generic/713.out | 38 ++++---- tests/generic/714 | 40 ++++---- tests/generic/714.out | 34 ++++--- tests/generic/715 | 26 +++-- tests/generic/715.out | 14 +-- tests/generic/716 | 4 - tests/generic/717 | 39 ++++---- tests/generic/717.out | 32 +++---- tests/generic/718 | 12 +- tests/generic/718.out | 2 tests/generic/719 | 4 - tests/generic/720 | 10 +- tests/generic/721 | 2 tests/generic/722 | 8 +- tests/generic/723 | 12 +- tests/generic/724 | 10 +- tests/generic/725 | 4 - tests/generic/726 | 4 - tests/generic/727 | 4 - tests/xfs/1213 | 73 +++++++++++++++ tests/xfs/1213.out | 2 tests/xfs/1214 | 232 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1214.out | 2 tests/xfs/1215 | 89 ++++++++++++++++++ tests/xfs/1215.out | 13 +++ tests/xfs/122.out | 6 + tests/xfs/206 | 1 tests/xfs/300 | 2 tests/xfs/443 | 4 - tests/xfs/789 | 4 - tests/xfs/790 | 10 +- tests/xfs/790.out | 2 tests/xfs/791 | 10 +- tests/xfs/791.out | 2 tests/xfs/792 | 4 - tests/xfs/795 | 2 57 files changed, 748 insertions(+), 349 deletions(-) create mode 100755 tests/generic/1221 create mode 100644 tests/generic/1221.out create mode 100755 tests/xfs/1213 create mode 100644 tests/xfs/1213.out create mode 100755 tests/xfs/1214 create mode 100644 tests/xfs/1214.out create mode 100755 tests/xfs/1215 create mode 100644 tests/xfs/1215.out
PATCH 1/11 misc: split swapext and exchangerange
From: Darrick J. Wong <[email protected]>
These two commands (and the kernel implementations) are splitting, so we need to split the xfs_io usage.
--- common/rc | 2 +- common/xfs | 2 +- tests/generic/709 | 2 +- tests/generic/710 | 2 +- tests/generic/711 | 2 +- tests/generic/712 | 2 +- tests/generic/713 | 4 ++-- tests/generic/714 | 4 ++-- tests/generic/715 | 4 ++-- tests/generic/716 | 2 +- tests/generic/717 | 2 +- tests/generic/718 | 2 +- tests/generic/719 | 2 +- tests/generic/720 | 2 +- tests/generic/722 | 4 ++-- tests/generic/723 | 6 +++--- tests/generic/724 | 4 ++-- tests/generic/725 | 2 +- tests/generic/726 | 2 +- tests/generic/727 | 2 +- tests/xfs/789 | 2 +- tests/xfs/790 | 2 +- tests/xfs/791 | 4 ++-- tests/xfs/792 | 2 +- 24 files changed, 32 insertions(+), 32 deletions(-)
common/rc +1 -1
@@ -2771,7 +2771,7 @@ _require_xfs_io_command() _notrun "xfs_io $command $param kernel support is missing" param_checked="$param" ;; - "swapext") + "swapext"|"exchangerange") $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 128k -b 128k' $testfile > /dev/null $XFS_IO_PROG -f -c 'truncate 128k' $testfile.1 > /dev/null testio=`$XFS_IO_PROG -c "$command $param $testfile.1" $testfile 2>&1`
common/xfs +1 -1
@@ -1823,7 +1823,7 @@ _require_xfs_scratch_atomicswap() { _require_xfs_mkfs_atomicswap _require_scratch - _require_xfs_io_command swapext '-v exchrange -a' + _require_xfs_io_command exchangerange _scratch_mkfs -m reflink=1 > /dev/null _try_scratch_mount || \ _notrun "atomicswap dependencies not supported by scratch filesystem type: $FSTYP"
tests/generic/709 +1 -1
@@ -14,7 +14,7 @@ _begin_fstest auto quick fiexchange swapext quota . ./common/quota # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command swapext _require_user _require_nobody _require_quota
tests/generic/710 +1 -1
@@ -14,7 +14,7 @@ _begin_fstest auto quick fiexchange swapext quota . ./common/quota # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command swapext _require_user _require_nobody _require_quota
tests/generic/711 +1 -1
@@ -21,7 +21,7 @@ _cleanup() . ./common/filter # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command swapext _require_test dir=$TEST_DIR/test-$seq
tests/generic/712 +1 -1
@@ -21,7 +21,7 @@ _cleanup() # real QA test starts here _require_test_program punch-alternating -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_test dir=$TEST_DIR/test-$seq
tests/generic/713 +2 -2
@@ -21,7 +21,7 @@ _cleanup() . ./common/reflink # real QA test starts here -_require_xfs_io_command swapext '-v exchrange -s 64k -l 64k' +_require_xfs_io_command exchangerange ' -s 64k -l 64k' _require_xfs_io_command "falloc" _require_test
@@ -36,7 +36,7 @@ filesnap() { test_swapext_once() { filesnap "$1: before swapext" $dir/$3 $dir/$4 - $XFS_IO_PROG -c "swapext -v exchrange $2 $dir/$3" $dir/$4 + $XFS_IO_PROG -c "exchangerange $2 $dir/$3" $dir/$4 filesnap "$1: after swapext" $dir/$3 $dir/$4 _test_cycle_mount filesnap "$1: after cycling mount" $dir/$3 $dir/$4
tests/generic/714 +2 -2
@@ -22,7 +22,7 @@ _cleanup() . ./common/reflink # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_xfs_io_command "falloc" _require_test_reflink
@@ -37,7 +37,7 @@ filesnap() { test_swapext_once() { filesnap "$1: before swapext" $dir/$3 $dir/$4 - $XFS_IO_PROG -c "swapext -v exchrange $2 $dir/$3" $dir/$4 + $XFS_IO_PROG -c "exchangerange $2 $dir/$3" $dir/$4 filesnap "$1: after swapext" $dir/$3 $dir/$4 _test_cycle_mount filesnap "$1: after cycling mount" $dir/$3 $dir/$4
tests/generic/715 +2 -2
@@ -21,7 +21,7 @@ _cleanup() . ./common/reflink # real QA test starts here -_require_xfs_io_command swapext '-v exchrange -s 64k -l 64k' +_require_xfs_io_command exchangerange ' -s 64k -l 64k' _require_test filesnap() {
@@ -51,7 +51,7 @@ test_swapext_once() { _pwrite_byte 0x59 0 $((blksz * b_len)) $dir/b >> $seqres.full filesnap "$tag: before swapext" $dir/a $dir/b - cmd="swapext -v exchrange -s $((blksz * a_off)) -d $((blksz * b_off)) $len $dir/a" + cmd="exchangerange -s $((blksz * a_off)) -d $((blksz * b_off)) $len $dir/a" echo "$cmd" >> $seqres.full $XFS_IO_PROG -c "$cmd" $dir/b filesnap "$tag: after swapext" $dir/a $dir/b
tests/generic/716 +1 -1
@@ -24,7 +24,7 @@ _cleanup() . ./common/reflink # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate _require_test_reflink _require_test
tests/generic/717 +1 -1
@@ -21,7 +21,7 @@ _cleanup() . ./common/reflink # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate _require_test _require_scratch
tests/generic/718 +1 -1
@@ -21,7 +21,7 @@ _cleanup() . ./common/reflink # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_test dir=$TEST_DIR/test-$seq
tests/generic/719 +1 -1
@@ -23,7 +23,7 @@ _cleanup() . ./common/filter # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate '-e' _require_test
tests/generic/720 +1 -1
@@ -20,7 +20,7 @@ _cleanup() . ./common/filter # real QA test starts here -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_test_program punch-alternating _require_test
tests/generic/722 +2 -2
@@ -23,7 +23,7 @@ _cleanup() # real QA test starts here _require_test_program "punch-alternating" -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_scratch _require_scratch_shutdown
@@ -43,7 +43,7 @@ od -tx1 -Ad -c $SCRATCH_MNT/a > /tmp/a0 od -tx1 -Ad -c $SCRATCH_MNT/b > /tmp/b0 echo swap >> $seqres.full -$XFS_IO_PROG -c "swapext -v exchrange -a -e -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b +$XFS_IO_PROG -c "exchangerange -e -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b _scratch_shutdown _scratch_cycle_mount
tests/generic/723 +3 -3
@@ -22,7 +22,7 @@ _cleanup() # real QA test starts here _require_test_program "punch-alternating" -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command exchangerange _require_scratch _scratch_mkfs >> $seqres.full
@@ -41,7 +41,7 @@ echo "md5 a: $old_a md5 b: $old_b" >> $seqres.full # Test swapext with the -n option, which will do all the input parameter # checking and return 0 without changing anything. echo dry run swap >> $seqres.full -$XFS_IO_PROG -c "swapext -v exchrange -n -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b +$XFS_IO_PROG -c "exchangerange -n -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b _scratch_cycle_mount new_a=$(md5sum $SCRATCH_MNT/a | awk '{print $1}')
@@ -54,7 +54,7 @@ test $old_b = $new_b || echo "scratch file B should not have swapped" # Do it again, but without the -n option, to prove that we can actually # swap the file contents. echo actual swap >> $seqres.full -$XFS_IO_PROG -c "swapext -v exchrange -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b +$XFS_IO_PROG -c "exchangerange -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b _scratch_cycle_mount new_a=$(md5sum $SCRATCH_MNT/a | awk '{print $1}')
tests/generic/724 +2 -2
@@ -22,7 +22,7 @@ _cleanup() . ./common/filter # real QA test starts here -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_scratch _scratch_mkfs >> $seqres.full
@@ -42,7 +42,7 @@ md5sum $SCRATCH_MNT/b | _filter_scratch # Test swapext. -h means skip holes in /b, and -e means operate to EOF echo swap | tee -a $seqres.full -$XFS_IO_PROG -c "swapext -v exchrange -f -u -h -e -a $SCRATCH_MNT/b" $SCRATCH_MNT/a +$XFS_IO_PROG -c "exchangerange -f -u -h -e $SCRATCH_MNT/b" $SCRATCH_MNT/a _scratch_cycle_mount md5sum $SCRATCH_MNT/a | _filter_scratch
tests/generic/725 +1 -1
@@ -22,7 +22,7 @@ _cleanup() . ./common/filter # real QA test starts here -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate '-e' _require_scratch
tests/generic/726 +1 -1
@@ -25,7 +25,7 @@ _begin_fstest auto fiexchange swapext quick # Modify as appropriate. _supported_fs generic _require_user -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate _require_scratch
tests/generic/727 +1 -1
@@ -28,7 +28,7 @@ _supported_fs generic _require_user _require_command "$GETCAP_PROG" getcap _require_command "$SETCAP_PROG" setcap -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate _require_scratch _require_attrs security
tests/xfs/789 +1 -1
@@ -21,7 +21,7 @@ _cleanup() # real QA test starts here _supported_fs xfs -_require_xfs_io_command swapext '-v exchrange' +_require_xfs_io_command swapext _require_test # We can't do any reasonable swapping if the files we're going to create are
tests/xfs/790 +1 -1
@@ -24,7 +24,7 @@ _cleanup() # real QA test starts here _supported_fs xfs -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_test_program "punch-alternating" _require_xfs_io_command startupdate _require_xfs_io_error_injection "bmap_finish_one"
tests/xfs/791 +2 -2
@@ -25,7 +25,7 @@ _cleanup() # real QA test starts here _supported_fs xfs -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_xfs_scratch_atomicswap _require_xfs_io_error_injection "bmap_finish_one"
@@ -48,7 +48,7 @@ md5sum $SCRATCH_MNT/b | _filter_scratch # Test swapext. -h means skip holes in /b, and -e means operate to EOF echo swap | tee -a $seqres.full $XFS_IO_PROG -x -c 'inject bmap_finish_one' \ - -c "swapext -v exchrange -f -u -h -e -a $SCRATCH_MNT/b" $SCRATCH_MNT/a + -c "exchangerange -f -u -h -e $SCRATCH_MNT/b" $SCRATCH_MNT/a _scratch_cycle_mount md5sum $SCRATCH_MNT/a | _filter_scratch
tests/xfs/792 +1 -1
@@ -25,7 +25,7 @@ _cleanup() # real QA test starts here _supported_fs xfs -_require_xfs_io_command swapext '-v exchrange -a' +_require_xfs_io_command exchangerange _require_xfs_io_command startupdate '-e' _require_xfs_scratch_atomicswap _require_xfs_io_error_injection "bmap_finish_one"
PATCH 2/11 misc: change xfs_io -c swapext to exchangerange
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Update the swapext command to use exchangerange as part of severing the connection between the two ioctls.
Flags changed:
-h (only exchange written extents) is now -w.
-a (atomic mode) is always enabled now.
-e (to eof) is now the default; -l (length) disables this flag.
-u (unconditonal swap) is inverted to -c (commit only if fresh).
--- tests/generic/712 | 8 ++++---- tests/generic/713 | 38 +++++++++++++++++++------------------- tests/generic/713.out | 38 +++++++++++++++++++------------------- tests/generic/714 | 36 ++++++++++++++++++------------------ tests/generic/714.out | 34 +++++++++++++++++----------------- tests/generic/715 | 22 ++++++++++++---------- tests/generic/715.out | 14 +++++++------- tests/generic/716 | 2 +- tests/generic/717 | 34 +++++++++++++++++----------------- tests/generic/717.out | 32 ++++++++++++++++---------------- tests/generic/718 | 10 +++++----- tests/generic/718.out | 2 +- tests/generic/719 | 2 +- tests/generic/720 | 8 ++++---- tests/generic/721 | 2 +- tests/generic/722 | 6 +++--- tests/generic/723 | 10 +++++----- tests/generic/724 | 8 ++++---- tests/generic/725 | 2 +- tests/generic/726 | 2 +- tests/generic/727 | 2 +- tests/xfs/300 | 2 +- tests/xfs/443 | 4 ++-- tests/xfs/790 | 8 ++++---- tests/xfs/790.out | 2 +- tests/xfs/791 | 8 ++++---- tests/xfs/791.out | 2 +- tests/xfs/792 | 2 +- tests/xfs/795 | 2 +- 29 files changed, 172 insertions(+), 170 deletions(-)
tests/generic/712 +4 -4
@@ -4,10 +4,10 @@ # # FS QA Test No. 712 # -# Make sure that swapext modifies ctime and not mtime of the file. +# Make sure that exchangerange modifies ctime and not mtime of the file. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -39,8 +39,8 @@ old_mtime="$(echo $(stat -c '%y' $dir/a $dir/b))" old_ctime="$(echo $(stat -c '%z' $dir/a $dir/b))" stat -c '%y %Y %z %Z' $dir/a $dir/b >> $seqres.full -# Now try to swapext -$XFS_IO_PROG -c "swapext $dir/b" $dir/a +# Now try to exchangerange +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a # Snapshot the 'a' file after we swap echo after >> $seqres.full
tests/generic/713 +19 -19
@@ -4,10 +4,10 @@ # # FS QA Test No. 713 # -# Test swapext between ranges of two different files. +# Test exchangerange between ranges of two different files. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -34,26 +34,26 @@ filesnap() { fi } -test_swapext_once() { - filesnap "$1: before swapext" $dir/$3 $dir/$4 +test_exchangerange_once() { + filesnap "$1: before exchangerange" $dir/$3 $dir/$4 $XFS_IO_PROG -c "exchangerange $2 $dir/$3" $dir/$4 - filesnap "$1: after swapext" $dir/$3 $dir/$4 + filesnap "$1: after exchangerange" $dir/$3 $dir/$4 _test_cycle_mount filesnap "$1: after cycling mount" $dir/$3 $dir/$4 echo } -test_swapext_two() { - # swapext the same range of two files - test_swapext_once "$*: samerange" \ +test_exchangerange_two() { + # exchangerange the same range of two files + test_exchangerange_once "$*: samerange" \ "-s $((blksz * 3)) -d $((blksz * 3)) -l $((blksz * 5))" b a - # swapext different ranges of two files - test_swapext_once "$*: diffrange" \ + # exchangerange different ranges of two files + test_exchangerange_once "$*: diffrange" \ "-s $((blksz * 37)) -d $((blksz * 47)) -l $((blksz * 7))" b a - # swapext overlapping ranges of two files - test_swapext_once "$*: overlap" \ + # exchangerange overlapping ranges of two files + test_exchangerange_once "$*: overlap" \ "-s $((blksz * 17)) -d $((blksz * 23)) -l $((blksz * 7))" b a }
@@ -67,19 +67,19 @@ _require_congruent_file_oplen $TEST_DIR $blksz rm -rf $dir/a $dir/b _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full -test_swapext_two "simple" +test_exchangerange_two "simple" # Make some files that don't end an aligned offset. rm -rf $dir/a $dir/b _pwrite_byte 0x58 0 $(( (blksz * nrblks) + 37)) $dir/a >> $seqres.full _pwrite_byte 0x59 0 $(( (blksz * nrblks) + 37)) $dir/b >> $seqres.full -test_swapext_once "unalignedeof" "" a b +test_exchangerange_once "unalignedeof" "" a b # Set up some crazy rainbow files rm -rf $dir/a $dir/b _weave_file_rainbow $blksz $nrblks $dir/a >> $seqres.full _weave_file_rainbow $blksz $nrblks $dir/b >> $seqres.full -test_swapext_two "rainbow" +test_exchangerange_two "rainbow" # Now set up a simple file for testing within the same file rm -rf $dir/c
@@ -87,12 +87,12 @@ $XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((blksz * nrblks))" \ -c "pwrite -S 0x59 $((blksz * nrblks)) $((blksz * nrblks))" \ $dir/c >> $seqres.full -# swapext the same offset into the 'X' and 'Y' regions of the file -test_swapext_once "single: sameXandY" \ +# exchangerange the same offset into the 'X' and 'Y' regions of the file +test_exchangerange_once "single: sameXandY" \ "-s $((blksz * 3)) -d $((blksz * (nrblks + 3))) -l $((blksz * 5))" c c -# swapext the same offset into the 'X' and 'Y' regions of the file -test_swapext_once "single: overlap" \ +# exchangerange the same offset into the 'X' and 'Y' regions of the file +test_exchangerange_once "single: overlap" \ "-s $((blksz * 13)) -d $((blksz * 17)) -l $((blksz * 5))" c c # success, all done
tests/generic/713.out +19 -19
@@ -1,85 +1,85 @@ QA output created by 713 -simple: samerange: before swapext +simple: samerange: before exchangerange db85d578204631f2b4eb1e73974253c2 TEST_DIR/test-713/b d0425612f15c6071022cf7127620f63d TEST_DIR/test-713/a -simple: samerange: after swapext +simple: samerange: after exchangerange 20beef1c9ed7de02e4229c69bd43bd8f TEST_DIR/test-713/b e7697fa99d08f7eb76fa3fb963fe916a TEST_DIR/test-713/a simple: samerange: after cycling mount 20beef1c9ed7de02e4229c69bd43bd8f TEST_DIR/test-713/b e7697fa99d08f7eb76fa3fb963fe916a TEST_DIR/test-713/a -simple: diffrange: before swapext +simple: diffrange: before exchangerange 20beef1c9ed7de02e4229c69bd43bd8f TEST_DIR/test-713/b e7697fa99d08f7eb76fa3fb963fe916a TEST_DIR/test-713/a -simple: diffrange: after swapext +simple: diffrange: after exchangerange cd32ce54c295fcdf571ce7f8220fac56 TEST_DIR/test-713/b d9771c5bb6d9db00b9abe65a4410e1a6 TEST_DIR/test-713/a simple: diffrange: after cycling mount cd32ce54c295fcdf571ce7f8220fac56 TEST_DIR/test-713/b d9771c5bb6d9db00b9abe65a4410e1a6 TEST_DIR/test-713/a -simple: overlap: before swapext +simple: overlap: before exchangerange cd32ce54c295fcdf571ce7f8220fac56 TEST_DIR/test-713/b d9771c5bb6d9db00b9abe65a4410e1a6 TEST_DIR/test-713/a -simple: overlap: after swapext +simple: overlap: after exchangerange e0fff655f6a08fc2f03ee01e4767060c TEST_DIR/test-713/b ec7d764c85e583e305028c9cba5b25b6 TEST_DIR/test-713/a simple: overlap: after cycling mount e0fff655f6a08fc2f03ee01e4767060c TEST_DIR/test-713/b ec7d764c85e583e305028c9cba5b25b6 TEST_DIR/test-713/a -unalignedeof: before swapext +unalignedeof: before exchangerange 9f8c731a4f1946ffdda8c33e82417f2d TEST_DIR/test-713/a 7a5d2ba7508226751c835292e28cd227 TEST_DIR/test-713/b -unalignedeof: after swapext +unalignedeof: after exchangerange 7a5d2ba7508226751c835292e28cd227 TEST_DIR/test-713/a 9f8c731a4f1946ffdda8c33e82417f2d TEST_DIR/test-713/b unalignedeof: after cycling mount 7a5d2ba7508226751c835292e28cd227 TEST_DIR/test-713/a 9f8c731a4f1946ffdda8c33e82417f2d TEST_DIR/test-713/b -rainbow: samerange: before swapext +rainbow: samerange: before exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a -rainbow: samerange: after swapext +rainbow: samerange: after exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a rainbow: samerange: after cycling mount 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a -rainbow: diffrange: before swapext +rainbow: diffrange: before exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a -rainbow: diffrange: after swapext +rainbow: diffrange: after exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a rainbow: diffrange: after cycling mount 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a -rainbow: overlap: before swapext +rainbow: overlap: before exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-713/a -rainbow: overlap: after swapext +rainbow: overlap: after exchangerange 6753bc585e3c71d53bfaae11d2ffee99 TEST_DIR/test-713/b 39597abd4d9d0c9ceac22b77eb00c373 TEST_DIR/test-713/a rainbow: overlap: after cycling mount 6753bc585e3c71d53bfaae11d2ffee99 TEST_DIR/test-713/b 39597abd4d9d0c9ceac22b77eb00c373 TEST_DIR/test-713/a -single: sameXandY: before swapext +single: sameXandY: before exchangerange 39e17753fa9e923a3b5928e13775e358 TEST_DIR/test-713/c -single: sameXandY: after swapext +single: sameXandY: after exchangerange 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-713/c single: sameXandY: after cycling mount 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-713/c -single: overlap: before swapext +single: overlap: before exchangerange 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-713/c -swapext: Invalid argument -single: overlap: after swapext +exchangerange: Invalid argument +single: overlap: after exchangerange 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-713/c single: overlap: after cycling mount 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-713/c
tests/generic/714 +18 -18
@@ -4,11 +4,11 @@ # # FS QA Test No. 714 # -# Test swapext between ranges of two different files, when one of the files +# Test exchangerange between ranges of two different files, when one of the files # is shared. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -35,26 +35,26 @@ filesnap() { fi } -test_swapext_once() { - filesnap "$1: before swapext" $dir/$3 $dir/$4 +test_exchangerange_once() { + filesnap "$1: before exchangerange" $dir/$3 $dir/$4 $XFS_IO_PROG -c "exchangerange $2 $dir/$3" $dir/$4 - filesnap "$1: after swapext" $dir/$3 $dir/$4 + filesnap "$1: after exchangerange" $dir/$3 $dir/$4 _test_cycle_mount filesnap "$1: after cycling mount" $dir/$3 $dir/$4 echo } -test_swapext_two() { - # swapext the same range of two files - test_swapext_once "$*: samerange" \ +test_exchangerange_two() { + # exchangerange the same range of two files + test_exchangerange_once "$*: samerange" \ "-s $((blksz * 3)) -d $((blksz * 3)) -l $((blksz * 5))" b a - # swapext different ranges of two files - test_swapext_once "$*: diffrange" \ + # exchangerange different ranges of two files + test_exchangerange_once "$*: diffrange" \ "-s $((blksz * 37)) -d $((blksz * 47)) -l $((blksz * 7))" b a - # swapext overlapping ranges of two files - test_swapext_once "$*: overlap" \ + # exchangerange overlapping ranges of two files + test_exchangerange_once "$*: overlap" \ "-s $((blksz * 17)) -d $((blksz * 23)) -l $((blksz * 7))" b a # Now let's overwrite a entirely to make sure COW works
@@ -79,14 +79,14 @@ rm -f $dir/a $dir/b $dir/sharea _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full _cp_reflink $dir/a $dir/sharea -test_swapext_two "simple" +test_exchangerange_two "simple" # Set up some crazy rainbow files rm -f $dir/a $dir/b $dir/sharea _weave_file_rainbow $blksz $nrblks $dir/a >> $seqres.full _weave_file_rainbow $blksz $nrblks $dir/b >> $seqres.full _cp_reflink $dir/a $dir/sharea -test_swapext_two "rainbow" +test_exchangerange_two "rainbow" # Now set up a simple file for testing within the same file rm -f $dir/c $dir/sharec
@@ -95,12 +95,12 @@ $XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((blksz * nrblks))" \ $dir/c >> $seqres.full _cp_reflink $dir/c $dir/sharec -# swapext the same offset into the 'X' and 'Y' regions of the file -test_swapext_once "single: sameXandY" \ +# exchangerange the same offset into the 'X' and 'Y' regions of the file +test_exchangerange_once "single: sameXandY" \ "-s $((blksz * 3)) -d $((blksz * (nrblks + 3))) -l $((blksz * 5))" c c -# swapext the same offset into the 'X' and 'Y' regions of the file -test_swapext_once "single: overlap" \ +# exchangerange the same offset into the 'X' and 'Y' regions of the file +test_exchangerange_once "single: overlap" \ "-s $((blksz * 13)) -d $((blksz * 17)) -l $((blksz * 5))" c c # Now let's overwrite a entirely to make sure COW works
tests/generic/714.out +17 -17
@@ -1,28 +1,28 @@ QA output created by 714 -simple: samerange: before swapext +simple: samerange: before exchangerange db85d578204631f2b4eb1e73974253c2 TEST_DIR/test-714/b d0425612f15c6071022cf7127620f63d TEST_DIR/test-714/a -simple: samerange: after swapext +simple: samerange: after exchangerange 20beef1c9ed7de02e4229c69bd43bd8f TEST_DIR/test-714/b e7697fa99d08f7eb76fa3fb963fe916a TEST_DIR/test-714/a simple: samerange: after cycling mount 20beef1c9ed7de02e4229c69bd43bd8f TEST_DIR/test-714/b e7697fa99d08f7eb76fa3fb963fe916a TEST_DIR/test-714/a -simple: diffrange: before swapext +simple: diffrange: before exchangerange 20beef1c9ed7de02e4229c69bd43bd8f TEST_DIR/test-714/b e7697fa99d08f7eb76fa3fb963fe916a TEST_DIR/test-714/a -simple: diffrange: after swapext +simple: diffrange: after exchangerange cd32ce54c295fcdf571ce7f8220fac56 TEST_DIR/test-714/b d9771c5bb6d9db00b9abe65a4410e1a6 TEST_DIR/test-714/a simple: diffrange: after cycling mount cd32ce54c295fcdf571ce7f8220fac56 TEST_DIR/test-714/b d9771c5bb6d9db00b9abe65a4410e1a6 TEST_DIR/test-714/a -simple: overlap: before swapext +simple: overlap: before exchangerange cd32ce54c295fcdf571ce7f8220fac56 TEST_DIR/test-714/b d9771c5bb6d9db00b9abe65a4410e1a6 TEST_DIR/test-714/a -simple: overlap: after swapext +simple: overlap: after exchangerange e0fff655f6a08fc2f03ee01e4767060c TEST_DIR/test-714/b ec7d764c85e583e305028c9cba5b25b6 TEST_DIR/test-714/a simple: overlap: after cycling mount
@@ -34,30 +34,30 @@ d0425612f15c6071022cf7127620f63d TEST_DIR/test-714/sharea d0425612f15c6071022cf7127620f63d TEST_DIR/test-714/sharea d0425612f15c6071022cf7127620f63d TEST_DIR/test-714/sharea -rainbow: samerange: before swapext +rainbow: samerange: before exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a -rainbow: samerange: after swapext +rainbow: samerange: after exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a rainbow: samerange: after cycling mount 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a -rainbow: diffrange: before swapext +rainbow: diffrange: before exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a -rainbow: diffrange: after swapext +rainbow: diffrange: after exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a rainbow: diffrange: after cycling mount 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a -rainbow: overlap: before swapext +rainbow: overlap: before exchangerange 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/b 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/a -rainbow: overlap: after swapext +rainbow: overlap: after exchangerange 6753bc585e3c71d53bfaae11d2ffee99 TEST_DIR/test-714/b 39597abd4d9d0c9ceac22b77eb00c373 TEST_DIR/test-714/a rainbow: overlap: after cycling mount
@@ -69,17 +69,17 @@ overwrite A and B entirely 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/sharea 48b41ee1970eb71064b77181f42634cf TEST_DIR/test-714/sharea -single: sameXandY: before swapext +single: sameXandY: before exchangerange 39e17753fa9e923a3b5928e13775e358 TEST_DIR/test-714/c -single: sameXandY: after swapext +single: sameXandY: after exchangerange 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-714/c single: sameXandY: after cycling mount 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-714/c -single: overlap: before swapext +single: overlap: before exchangerange 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-714/c -swapext: Invalid argument -single: overlap: after swapext +exchangerange: Invalid argument +single: overlap: after exchangerange 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-714/c single: overlap: after cycling mount 8262c617070703fb0e2a28d8f05e3112 TEST_DIR/test-714/c
tests/generic/715 +12 -10
@@ -4,10 +4,10 @@ # # FS QA Test No. 715 # -# Test swapext between two files of unlike size. +# Test exchangerange between two files of unlike size. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -33,7 +33,7 @@ filesnap() { fi } -test_swapext_once() { +test_exchangerange_once() { local tag=$1 local a_len=$2 local b_len=$3
@@ -41,20 +41,22 @@ test_swapext_once() { local b_off=$5 local len=$6 - # len is either a block count or -e to swap to EOF - if [ "$len" != "-e" ]; then + # len is either a block count or "EOF" + if [ "$len" = "EOF" ]; then + len="" + else len="-l $((blksz * len))" fi rm -f $dir/a $dir/b _pwrite_byte 0x58 0 $((blksz * a_len)) $dir/a >> $seqres.full _pwrite_byte 0x59 0 $((blksz * b_len)) $dir/b >> $seqres.full - filesnap "$tag: before swapext" $dir/a $dir/b + filesnap "$tag: before exchangerange" $dir/a $dir/b cmd="exchangerange -s $((blksz * a_off)) -d $((blksz * b_off)) $len $dir/a" echo "$cmd" >> $seqres.full $XFS_IO_PROG -c "$cmd" $dir/b - filesnap "$tag: after swapext" $dir/a $dir/b + filesnap "$tag: after exchangerange" $dir/a $dir/b _test_cycle_mount filesnap "$tag: after cycling mount" $dir/a $dir/b
@@ -65,11 +67,11 @@ dir=$TEST_DIR/test-$seq mkdir -p $dir blksz=65536 -test_swapext_once "last 5 blocks" 27 37 22 32 5 +test_exchangerange_once "last 5 blocks" 27 37 22 32 5 -test_swapext_once "whole file to eof" 27 37 0 0 -e +test_exchangerange_once "whole file to eof" 27 37 0 0 EOF -test_swapext_once "blocks 30-40" 27 37 30 30 10 +test_exchangerange_once "blocks 30-40" 27 37 30 30 10 # success, all done status=0
tests/generic/715.out +7 -7
@@ -1,29 +1,29 @@ QA output created by 715 -last 5 blocks: before swapext +last 5 blocks: before exchangerange 207ea56e0ccbf50d38fd3a2d842aa170 TEST_DIR/test-715/a eb58941d31f5be1e4e22df8c536dd490 TEST_DIR/test-715/b -last 5 blocks: after swapext +last 5 blocks: after exchangerange 3f34470fe9feb8513d5f3a8538f2c5f3 TEST_DIR/test-715/a c3daca7dd9218371cd0dc64f11e4b0bf TEST_DIR/test-715/b last 5 blocks: after cycling mount 3f34470fe9feb8513d5f3a8538f2c5f3 TEST_DIR/test-715/a c3daca7dd9218371cd0dc64f11e4b0bf TEST_DIR/test-715/b -whole file to eof: before swapext +whole file to eof: before exchangerange 207ea56e0ccbf50d38fd3a2d842aa170 TEST_DIR/test-715/a eb58941d31f5be1e4e22df8c536dd490 TEST_DIR/test-715/b -whole file to eof: after swapext +whole file to eof: after exchangerange eb58941d31f5be1e4e22df8c536dd490 TEST_DIR/test-715/a 207ea56e0ccbf50d38fd3a2d842aa170 TEST_DIR/test-715/b whole file to eof: after cycling mount eb58941d31f5be1e4e22df8c536dd490 TEST_DIR/test-715/a 207ea56e0ccbf50d38fd3a2d842aa170 TEST_DIR/test-715/b -blocks 30-40: before swapext +blocks 30-40: before exchangerange 207ea56e0ccbf50d38fd3a2d842aa170 TEST_DIR/test-715/a eb58941d31f5be1e4e22df8c536dd490 TEST_DIR/test-715/b -swapext: Invalid argument -blocks 30-40: after swapext +exchangerange: Invalid argument +blocks 30-40: after exchangerange 207ea56e0ccbf50d38fd3a2d842aa170 TEST_DIR/test-715/a eb58941d31f5be1e4e22df8c536dd490 TEST_DIR/test-715/b blocks 30-40: after cycling mount
tests/generic/716 +1 -1
@@ -10,7 +10,7 @@ # and some of the contents are updated. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
tests/generic/717 +17 -17
@@ -7,7 +7,7 @@ # Try invalid parameters to see if they fail. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -39,62 +39,62 @@ _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/b >> $seqres.full echo Immutable files -$XFS_IO_PROG -c 'chattr +i' -c "swapext $dir/b" $dir/a +$XFS_IO_PROG -c 'chattr +i' -c "exchangerange $dir/b" $dir/a $CHATTR_PROG -i $dir/a echo Readonly files -$XFS_IO_PROG -r -c "swapext $dir/b" $dir/a +$XFS_IO_PROG -r -c "exchangerange $dir/b" $dir/a echo Directories -$XFS_IO_PROG -c "swapext $dir/b" $dir +$XFS_IO_PROG -c "exchangerange $dir/b" $dir echo Unaligned ranges -$XFS_IO_PROG -c "swapext -s 37 -d 61 -l 17 $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -s 37 -d 61 -l 17 $dir/b" $dir/a echo file1 range entirely beyond EOF -$XFS_IO_PROG -c "swapext -s $(( blksz * (nrblks + 500) )) -d 0 -l $blksz $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -s $(( blksz * (nrblks + 500) )) -d 0 -l $blksz $dir/b" $dir/a echo file2 range entirely beyond EOF -$XFS_IO_PROG -c "swapext -d $(( blksz * (nrblks + 500) )) -s 0 -l $blksz $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -d $(( blksz * (nrblks + 500) )) -s 0 -l $blksz $dir/b" $dir/a echo Both ranges entirely beyond EOF -$XFS_IO_PROG -c "swapext -d $(( blksz * (nrblks + 500) )) -s $(( blksz * (nrblks + 500) )) -l $blksz $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -d $(( blksz * (nrblks + 500) )) -s $(( blksz * (nrblks + 500) )) -l $blksz $dir/b" $dir/a echo file1 range crossing EOF -$XFS_IO_PROG -c "swapext -s $(( blksz * (nrblks - 1) )) -d 0 -l $((2 * blksz)) $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -s $(( blksz * (nrblks - 1) )) -d 0 -l $((2 * blksz)) $dir/b" $dir/a echo file2 range crossing EOF -$XFS_IO_PROG -c "swapext -d $(( blksz * (nrblks - 1) )) -s 0 -l $((2 * blksz)) $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -d $(( blksz * (nrblks - 1) )) -s 0 -l $((2 * blksz)) $dir/b" $dir/a echo Both ranges crossing EOF -$XFS_IO_PROG -c "swapext -d $(( blksz * (nrblks - 1) )) -s $(( blksz * (nrblks - 1) )) -l $((blksz * 2)) $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -d $(( blksz * (nrblks - 1) )) -s $(( blksz * (nrblks - 1) )) -l $((blksz * 2)) $dir/b" $dir/a echo file1 unaligned EOF to file2 nowhere near EOF _pwrite_byte 0x58 $((blksz * nrblks)) 37 $dir/a >> $seqres.full _pwrite_byte 0x59 $((blksz * nrblks)) 37 $dir/b >> $seqres.full -$XFS_IO_PROG -c "swapext -d 0 -s $(( blksz * nrblks )) -l 37 $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -d 0 -s $(( blksz * nrblks )) -l 37 $dir/b" $dir/a echo file2 unaligned EOF to file1 nowhere near EOF -$XFS_IO_PROG -c "swapext -s 0 -d $(( blksz * nrblks )) -l 37 $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange -s 0 -d $(( blksz * nrblks )) -l 37 $dir/b" $dir/a echo Files of unequal length _pwrite_byte 0x58 $((blksz * nrblks)) $((blksz * 2)) $dir/a >> $seqres.full _pwrite_byte 0x59 $((blksz * nrblks)) $blksz $dir/b >> $seqres.full -$XFS_IO_PROG -c "swapext $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a echo Files on different filesystems _pwrite_byte 0x58 0 $((blksz * nrblks)) $SCRATCH_MNT/c >> $seqres.full -$XFS_IO_PROG -c "swapext $SCRATCH_MNT/c" $dir/a +$XFS_IO_PROG -c "exchangerange $SCRATCH_MNT/c" $dir/a echo Files on different mounts mkdir -p $SCRATCH_MNT/xyz mount --bind $dir $SCRATCH_MNT/xyz --bind _pwrite_byte 0x60 0 $((blksz * (nrblks + 2))) $dir/c >> $seqres.full -$XFS_IO_PROG -c "swapext $SCRATCH_MNT/xyz/c" $dir/a +$XFS_IO_PROG -c "exchangerange $SCRATCH_MNT/xyz/c" $dir/a umount $SCRATCH_MNT/xyz echo Swapping a file with itself -$XFS_IO_PROG -c "swapext $dir/a" $dir/a +$XFS_IO_PROG -c "exchangerange $dir/a" $dir/a # success, all done status=0
tests/generic/717.out +16 -16
@@ -1,33 +1,33 @@ QA output created by 717 Immutable files -swapext: Operation not permitted +exchangerange: Operation not permitted Readonly files -swapext: Bad file descriptor +exchangerange: Bad file descriptor Directories -swapext: Is a directory +exchangerange: Is a directory Unaligned ranges -swapext: Invalid argument +exchangerange: Invalid argument file1 range entirely beyond EOF -swapext: Invalid argument +exchangerange: Invalid argument file2 range entirely beyond EOF -swapext: Invalid argument +exchangerange: Invalid argument Both ranges entirely beyond EOF -swapext: Invalid argument +exchangerange: Invalid argument file1 range crossing EOF -swapext: Invalid argument +exchangerange: Invalid argument file2 range crossing EOF -swapext: Invalid argument +exchangerange: Invalid argument Both ranges crossing EOF -swapext: Invalid argument +exchangerange: Invalid argument file1 unaligned EOF to file2 nowhere near EOF -swapext: Invalid argument +exchangerange: Invalid argument file2 unaligned EOF to file1 nowhere near EOF -swapext: Invalid argument +exchangerange: Invalid argument Files of unequal length -swapext: Bad address +exchangerange: Bad address Files on different filesystems -swapext: Invalid cross-device link +exchangerange: Invalid cross-device link Files on different mounts -swapext: Invalid cross-device link +exchangerange: Invalid cross-device link Swapping a file with itself -swapext: Invalid argument +exchangerange: Invalid argument
tests/generic/718 +5 -5
@@ -4,10 +4,10 @@ # # FS QA Test No. 718 # -# Make sure swapext honors RLIMIT_FSIZE. +# Make sure exchangerange honors RLIMIT_FSIZE. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -29,7 +29,7 @@ mkdir -p $dir blksz=65536 nrblks=64 -# Create some 4M files to test swapext +# Create some 4M files to test exchangerange _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full sync
@@ -39,8 +39,8 @@ md5sum $dir/a $dir/b | _filter_test_dir ulimit -f $(( (blksz * 2) / 512)) ulimit -a >> $seqres.full -# Now try to swapext -$XFS_IO_PROG -c "swapext $dir/b" $dir/a +# Now try to exchangerange +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a md5sum $dir/a $dir/b | _filter_test_dir # success, all done
tests/generic/718.out +1 -1
@@ -1,6 +1,6 @@ QA output created by 718 d712f003e9d467e063cda1baf319b928 TEST_DIR/test-718/a 901e136269b8d283d311697b7c6dc1f2 TEST_DIR/test-718/b -swapext: Invalid argument +exchangerange: Invalid argument d712f003e9d467e063cda1baf319b928 TEST_DIR/test-718/a 901e136269b8d283d311697b7c6dc1f2 TEST_DIR/test-718/b
tests/generic/719 +1 -1
@@ -10,7 +10,7 @@ # caller wants a full file replacement. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
tests/generic/720 +4 -4
@@ -7,7 +7,7 @@ # Stress testing with a lot of extents. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -31,18 +31,18 @@ nrblks=$((LOAD_FACTOR * 100000)) _require_fs_space $TEST_DIR $(( (2 * blksz * nrblks) / 1024 )) -# Create some big swiss cheese files to test swapext with a lot of extents +# Create some big swiss cheese files to test exchangerange with a lot of extents _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full $here/src/punch-alternating $dir/a _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full $here/src/punch-alternating -o 1 $dir/b filefrag -v $dir/a $dir/b >> $seqres.full -# Now try to swapext +# Now try to exchangerange md5_a="$(md5sum < $dir/a)" md5_b="$(md5sum < $dir/b)" date >> $seqres.full -$XFS_IO_PROG -c "swapext $dir/b" $dir/a +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a date >> $seqres.full echo "md5_a=$md5_a" >> $seqres.full
tests/generic/721 +1 -1
@@ -8,7 +8,7 @@ # the staging file; and (b) when the staging file is created empty. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
tests/generic/722 +3 -3
@@ -4,11 +4,11 @@ # # FS QA Test No. 722 # -# Test swapext with the fsync flag flushes everything to disk before the call +# Test exchangerange with the fsync flag flushes everything to disk before the call # returns. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -43,7 +43,7 @@ od -tx1 -Ad -c $SCRATCH_MNT/a > /tmp/a0 od -tx1 -Ad -c $SCRATCH_MNT/b > /tmp/b0 echo swap >> $seqres.full -$XFS_IO_PROG -c "exchangerange -e -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b +$XFS_IO_PROG -c "exchangerange -f $SCRATCH_MNT/a" $SCRATCH_MNT/b _scratch_shutdown _scratch_cycle_mount
tests/generic/723 +5 -5
@@ -4,10 +4,10 @@ # # FS QA Test No. 723 # -# Test swapext with the dry run flag doesn't change anything. +# Test exchangerange with the dry run flag doesn't change anything. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -38,10 +38,10 @@ old_a=$(md5sum $SCRATCH_MNT/a | awk '{print $1}') old_b=$(md5sum $SCRATCH_MNT/b | awk '{print $1}') echo "md5 a: $old_a md5 b: $old_b" >> $seqres.full -# Test swapext with the -n option, which will do all the input parameter +# Test exchangerange with the -n option, which will do all the input parameter # checking and return 0 without changing anything. echo dry run swap >> $seqres.full -$XFS_IO_PROG -c "exchangerange -n -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b +$XFS_IO_PROG -c "exchangerange -n -f $SCRATCH_MNT/a" $SCRATCH_MNT/b _scratch_cycle_mount new_a=$(md5sum $SCRATCH_MNT/a | awk '{print $1}')
@@ -54,7 +54,7 @@ test $old_b = $new_b || echo "scratch file B should not have swapped" # Do it again, but without the -n option, to prove that we can actually # swap the file contents. echo actual swap >> $seqres.full -$XFS_IO_PROG -c "exchangerange -f -u $SCRATCH_MNT/a" $SCRATCH_MNT/b +$XFS_IO_PROG -c "exchangerange -f $SCRATCH_MNT/a" $SCRATCH_MNT/b _scratch_cycle_mount new_a=$(md5sum $SCRATCH_MNT/a | awk '{print $1}')
tests/generic/724 +4 -4
@@ -5,11 +5,11 @@ # FS QA Test No. 724 # # Test scatter-gather atomic file writes. We create a temporary file, write -# sparsely to it, then use XFS_EXCH_RANGE_FILE1_WRITTEN flag to swap +# sparsely to it, then use XFS_EXCHRANGE_FILE1_WRITTEN flag to swap # atomicallly only the ranges that we wrote. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -40,9 +40,9 @@ _pwrite_byte 0x57 768k 64k $SCRATCH_MNT/b >> $seqres.full md5sum $SCRATCH_MNT/a | _filter_scratch md5sum $SCRATCH_MNT/b | _filter_scratch -# Test swapext. -h means skip holes in /b, and -e means operate to EOF +# Test exchangerange. -w means skip holes in /b echo swap | tee -a $seqres.full -$XFS_IO_PROG -c "exchangerange -f -u -h -e $SCRATCH_MNT/b" $SCRATCH_MNT/a +$XFS_IO_PROG -c "exchangerange -f -w $SCRATCH_MNT/b" $SCRATCH_MNT/a _scratch_cycle_mount md5sum $SCRATCH_MNT/a | _filter_scratch
tests/generic/725 +1 -1
@@ -9,7 +9,7 @@ # perform the scattered update. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
tests/generic/726 +1 -1
@@ -8,7 +8,7 @@ # commit. # . ./common/preamble -_begin_fstest auto fiexchange swapext quick +_begin_fstest auto fiexchange quick # Override the default cleanup function. # _cleanup()
tests/generic/727 +1 -1
@@ -8,7 +8,7 @@ # commit. # . ./common/preamble -_begin_fstest auto fiexchange swapext quick +_begin_fstest auto fiexchange quick # Override the default cleanup function. # _cleanup()
tests/xfs/300 +1 -1
@@ -4,7 +4,7 @@ # # FS QA Test No. 300 # -# Test xfs_fsr / swapext management of di_forkoff w/ selinux +# Test xfs_fsr / exchangerange management of di_forkoff w/ selinux # . ./common/preamble _begin_fstest auto fsr
tests/xfs/443 +2 -2
@@ -29,7 +29,7 @@ _require_scratch _require_test_program "punch-alternating" _require_xfs_io_command "falloc" _require_xfs_io_command "fpunch" -_require_xfs_io_command "swapext" +_require_xfs_io_command "exchangerange" _require_xfs_io_command "fiemap" _scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs
@@ -56,7 +56,7 @@ $here/src/punch-alternating $file2 for i in $(seq 1 2 399); do # punch one extent from the tmpfile and swap $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2 - $XFS_IO_PROG -c "swapext $file2" $file1 + $XFS_IO_PROG -c "exchangerange $file2" $file1 # punch the same extent from the old fork (now in file2) to resync the # extent counts and repeat
tests/xfs/790 +4 -4
@@ -4,11 +4,11 @@ # # FS QA Test No. 790 # -# Make sure an atomic swapext actually runs to completion even if we shut +# Make sure an atomic exchangerange actually runs to completion even if we shut # down the filesystem midway through. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -49,9 +49,9 @@ _pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/c >> $seqres.full _pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full sync -# Inject a bmap error and trigger it via swapext. +# Inject a bmap error and trigger it via exchangerange. filesnap "before commit" -$XFS_IO_PROG -x -c 'inject bmap_finish_one' -c "swapext $dir/b" $dir/a +$XFS_IO_PROG -x -c 'inject bmap_finish_one' -c "exchangerange $dir/b" $dir/a # Check the file afterwards. _test_cycle_mount
tests/xfs/790.out +1 -1
@@ -3,7 +3,7 @@ before commit c7221b1494117327570a0958b0abca51 TEST_DIR/test-790/a 30cc2b6b307081e10972317013efb0f3 TEST_DIR/test-790/b 30cc2b6b307081e10972317013efb0f3 TEST_DIR/test-790/c -swapext: Input/output error +exchangerange: Input/output error after commit 30cc2b6b307081e10972317013efb0f3 TEST_DIR/test-790/a c7221b1494117327570a0958b0abca51 TEST_DIR/test-790/b
tests/xfs/791 +4 -4
@@ -5,12 +5,12 @@ # FS QA Test No. 791 # # Test scatter-gather atomic file writes. We create a temporary file, write -# sparsely to it, then use XFS_EXCH_RANGE_FILE1_WRITTEN flag to swap +# sparsely to it, then use XFS_EXCHRANGE_FILE1_WRITTEN flag to swap # atomicallly only the ranges that we wrote. Inject an error so that we can # test that log recovery finishes the swap. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
@@ -45,10 +45,10 @@ sync md5sum $SCRATCH_MNT/a | _filter_scratch md5sum $SCRATCH_MNT/b | _filter_scratch -# Test swapext. -h means skip holes in /b, and -e means operate to EOF +# Test exchangerange. -w means skip holes in /b echo swap | tee -a $seqres.full $XFS_IO_PROG -x -c 'inject bmap_finish_one' \ - -c "exchangerange -f -u -h -e $SCRATCH_MNT/b" $SCRATCH_MNT/a + -c "exchangerange -f -w $SCRATCH_MNT/b" $SCRATCH_MNT/a _scratch_cycle_mount md5sum $SCRATCH_MNT/a | _filter_scratch
tests/xfs/791.out +1 -1
@@ -2,6 +2,6 @@ QA output created by 791 310f146ce52077fcd3308dcbe7632bb2 SCRATCH_MNT/a c9fb827e2e3e579dc2a733ddad486d1d SCRATCH_MNT/b swap -swapext: Input/output error +exchangerange: Input/output error e9cbfe8489a68efaa5fcf40cf3106118 SCRATCH_MNT/a faf8ed02a5b0638096a817abcc6c2127 SCRATCH_MNT/b
tests/xfs/792 +1 -1
@@ -10,7 +10,7 @@ # recovery finishes the swap. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick fiexchange # Override the default cleanup function. _cleanup()
tests/xfs/795 +1 -1
@@ -6,7 +6,7 @@ # # Ensure that the sysadmin won't hit EDQUOT while repairing file data contents # even if the file's quota limits have been exceeded. This tests the quota -# reservation handling inside the swapext code used by repair. +# reservation handling inside the exchangerange code used by repair. # . ./common/preamble _begin_fstest online_repair
PATCH 3/11 generic/709,710: rework these for exchangerange vs. quota testing
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The exchange-range implementation is now completely separate from the old swapext ioctl, so let's migrate these quota tests to exchangerange.
There's no point in maintaining these tests for the legacy swapext code because it returns EINVAL if any quota is enabled and the two files have different user/group/project ids. Originally I had forward ported the old swapext ioctl to use commitrange as its backend, but that will be dropped in favor of porting xfs_fsr to use commitrange directly.
--- tests/generic/709 | 12 ++++++------ tests/generic/710 | 14 +++++++------- tests/generic/710.out | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)
tests/generic/709 +6 -6
@@ -4,17 +4,17 @@ # # FS QA Test No. 709 # -# Can we use swapext to make the quota accounting incorrect? +# Can we use exchangerange to make the quota accounting incorrect? . ./common/preamble -_begin_fstest auto quick fiexchange swapext quota +_begin_fstest auto quick fiexchange quota # Import common functions. . ./common/filter . ./common/quota # real QA test starts here -_require_xfs_io_command swapext +_require_xfs_io_command exchangerange _require_user _require_nobody _require_quota
@@ -32,7 +32,7 @@ chown $qa_user $SCRATCH_MNT/a $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 64k -b 64k' -c 'truncate 256k' $SCRATCH_MNT/b >> $seqres.full chown nobody $SCRATCH_MNT/b -echo before swapext >> $seqres.full +echo before exchangerange >> $seqres.full $XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full stat $SCRATCH_MNT/* >> $seqres.full
@@ -40,11 +40,11 @@ stat $SCRATCH_MNT/* >> $seqres.full # fail with -EINVAL (since that's what the first kernel fix does) or succeed # (because subsequent rewrites can handle quota). Whatever the outcome, the # quota usage check at the end should never show a discrepancy. -$XFS_IO_PROG -c "swapext $SCRATCH_MNT/b" $SCRATCH_MNT/a &> $tmp.swap +$XFS_IO_PROG -c "exchangerange $SCRATCH_MNT/b" $SCRATCH_MNT/a &> $tmp.swap cat $tmp.swap >> $seqres.full grep -v 'Invalid argument' $tmp.swap -echo after swapext >> $seqres.full +echo after exchangerange >> $seqres.full $XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full stat $SCRATCH_MNT/* >> $seqres.full
tests/generic/710 +7 -7
@@ -4,17 +4,17 @@ # # FS QA Test No. 710 # -# Can we use swapext to exceed the quota enforcement? +# Can we use exchangerange to exceed the quota enforcement? . ./common/preamble -_begin_fstest auto quick fiexchange swapext quota +_begin_fstest auto quick fiexchange quota # Import common functions. . ./common/filter . ./common/quota # real QA test starts here -_require_xfs_io_command swapext +_require_xfs_io_command exchangerange _require_user _require_nobody _require_quota
@@ -35,14 +35,14 @@ chown nobody $SCRATCH_MNT/b # Set up a quota limit $XFS_QUOTA_PROG -x -c "limit -u bhard=70k nobody" $SCRATCH_MNT -echo before swapext >> $seqres.full +echo before exchangerange >> $seqres.full $XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full stat $SCRATCH_MNT/* >> $seqres.full -# Now try to swapext -$XFS_IO_PROG -c "swapext $SCRATCH_MNT/b" $SCRATCH_MNT/a +# Now try to exchangerange +$XFS_IO_PROG -c "exchangerange $SCRATCH_MNT/b" $SCRATCH_MNT/a -echo after swapext >> $seqres.full +echo after exchangerange >> $seqres.full $XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full stat $SCRATCH_MNT/* >> $seqres.full
tests/generic/710.out +1 -1
@@ -1,4 +1,4 @@ QA output created by 710 -swapext: Disk quota exceeded +exchangerange: Disk quota exceeded Comparing user usage Comparing group usage
Re: [PATCH 03/11] generic/709,710: rework these for exchangerange vs. quota testing
Looks good:
PATCH 4/11 generic/711,xfs/537: actually fork these tests for exchange-range
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Fork these tests to check the same things with exchange-range as they do for swapext, since the code porting swapext to commit-range has been dropped.
I was going to fork xfs/789 as well, but it turns out that generic/714 covers this sufficiently so for that one, we just strike fiexchange from the group tag.
--- tests/generic/1221 | 45 ++++++++++++++++++++++++ tests/generic/1221.out | 2 + tests/generic/711 | 2 + tests/xfs/1215 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1215.out | 13 +++++++ tests/xfs/789 | 2 + 6 files changed, 151 insertions(+), 2 deletions(-) create mode 100755 tests/generic/1221 create mode 100644 tests/generic/1221.out create mode 100755 tests/xfs/1215 create mode 100644 tests/xfs/1215.out
tests/generic/1221 new file +45 -0
@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1221 +# +# Make sure that exchangerange won't touch a swap file. + +. ./common/preamble +_begin_fstest auto quick fiexchange + +# Override the default cleanup function. +_cleanup() +{ + cd / + test -e "$dir/a" && swapoff $dir/a + rm -r -f $tmp.* $dir +} + +# Import common functions. +. ./common/filter + +# real QA test starts here +_require_xfs_io_command exchangerange +_require_test + +dir=$TEST_DIR/test-$seq +mkdir -p $dir + +# Set up a fragmented swapfile and a dummy donor file. +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$here/src/punch-alternating $dir/a +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$MKSWAP_PROG $dir/a >> $seqres.full + +$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 32m -b 1m' $dir/b >> $seqres.full + +swapon $dir/a || _notrun 'failed to swapon' + +# Now try to exchangerange. +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a + +# success, all done +status=0 +exit
tests/generic/1221.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1221 +exchangerange: Text file busy
tests/generic/711 +1 -1
@@ -7,7 +7,7 @@ # Make sure that swapext won't touch a swap file. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()
tests/xfs/1215 new file +89 -0
89 lines not on this page · raw message
tests/xfs/1215.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 1215 +* Exchange extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 18 blocks +Fragment $srcfile +Collect $donorfile's extent count +Collect $srcfile's extent count +Inject reduce_max_iextents error tag +Exchange $srcfile's and $donorfile's extent forks +Check for $donorfile's extent count overflow +Check for $srcfile's extent count overflow
tests/xfs/789 +1 -1
@@ -7,7 +7,7 @@ # Simple tests of the old xfs swapext ioctl . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()
Re: [PATCH 04/11] generic/711,xfs/537: actually fork these tests for exchange-range
Looks good:
Re: [PATCH 04/11] generic/711,xfs/537: actually fork these tests for exchange-range
In reply to Darrick J. WongQuoted 10 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Fork these tests to check the same things with exchange-range as they do for swapext, since the code porting swapext to commit-range has been dropped.
I was going to fork xfs/789 as well, but it turns out that generic/714 covers this sufficiently so for that one, we just strike fiexchange from the group tag.
Quoted 8 lines
Signed-off-by Darrick J. Wong <[email protected]>--- tests/generic/1221 | 45 ++++++++++++++++++++++++ tests/generic/1221.out | 2 + tests/generic/711 | 2 + tests/xfs/1215 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1215.out | 13 +++++++ tests/xfs/789 | 2 +
Shouldn't the "xfs/537" (in subject) be xfs/789? I'll change that when I merge it.
Thanks,
Zorro
Quoted 208 lines
6 files changed, 151 insertions(+), 2 deletions(-) create mode 100755 tests/generic/1221 create mode 100644 tests/generic/1221.out create mode 100755 tests/xfs/1215 create mode 100644 tests/xfs/1215.outtests/generic/1221 new file +45
-0@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1221 +# +# Make sure that exchangerange won't touch a swap file. + +. ./common/preamble +_begin_fstest auto quick fiexchange + +# Override the default cleanup function. +_cleanup() +{ + cd / + test -e "$dir/a" && swapoff $dir/a + rm -r -f $tmp.* $dir +} + +# Import common functions. +. ./common/filter + +# real QA test starts here +_require_xfs_io_command exchangerange +_require_test + +dir=$TEST_DIR/test-$seq +mkdir -p $dir + +# Set up a fragmented swapfile and a dummy donor file. +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$here/src/punch-alternating $dir/a +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$MKSWAP_PROG $dir/a >> $seqres.full + +$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 32m -b 1m' $dir/b >> $seqres.full + +swapon $dir/a || _notrun 'failed to swapon' + +# Now try to exchangerange. +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a + +# success, all done +status=0 +exittests/generic/1221.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 1221 +exchangerange: Text file busytests/generic/711 +1
-1@@ -7,7 +7,7 @@ # Make sure that swapext won't touch a swap file. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()tests/xfs/1215 new file +89
-0@@ -0,0 +1,89 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1215 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# exchanging ranges between files +. ./common/preamble +_begin_fstest auto quick collapse fiexchange + +# Import common functions. +. ./common/filter +. ./common/inject + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_scratch_rmapbt +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "exchangerange" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Exchange extent forks" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +donorfile=${SCRATCH_MNT}/donorfile + +echo "Create \$donorfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((17 * bsize)) 0 $((17 * bsize))" $donorfile \ + >> $seqres.full + +# After the for loop the donor file will have the following extent layout +# | 0-4 | 5 | 6 | 7 | 8 | 9 | 10 | +echo "Fragment \$donorfile" +for i in $(seq 5 10); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done + +echo "Create \$srcfile having an extent of length 18 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((18 * bsize)) 0 $((18 * bsize))" $srcfile \ + >> $seqres.full + +echo "Fragment \$srcfile" +# After the for loop the src file will have the following extent layout +# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7-10 | +for i in $(seq 1 7); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$(_xfs_get_fsxattr nextents $donorfile) + +echo "Collect \$srcfile's extent count" +src_nr_exts=$(_xfs_get_fsxattr nextents $srcfile) + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Exchange \$srcfile's and \$donorfile's extent forks" +$XFS_IO_PROG -f -c "exchangerange $donorfile" $srcfile >> $seqres.full 2>&1 + +echo "Check for \$donorfile's extent count overflow" +nextents=$(_xfs_get_fsxattr nextents $donorfile) + +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$(_xfs_get_fsxattr nextents $srcfile) + +if (( $nextents == $donor_nr_exts )); then + echo "\$srcfile: Extent count overflow check failed" +fi + +# success, all done +status=0 +exittests/xfs/1215.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 1215 +* Exchange extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 18 blocks +Fragment $srcfile +Collect $donorfile's extent count +Collect $srcfile's extent count +Inject reduce_max_iextents error tag +Exchange $srcfile's and $donorfile's extent forks +Check for $donorfile's extent count overflow +Check for $srcfile's extent count overflowtests/xfs/789 +1
-1@@ -7,7 +7,7 @@ # Simple tests of the old xfs swapext ioctl . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()
Re: [PATCH 04/11] generic/711,xfs/537: actually fork these tests for exchange-range
Quoted 20 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Fork these tests to check the same things with exchange-range as they do for swapext, since the code porting swapext to commit-range has been dropped.
I was going to fork xfs/789 as well, but it turns out that generic/714 covers this sufficiently so for that one, we just strike fiexchange from the group tag.
Quoted 8 lines
Signed-off-by Darrick J. Wong <[email protected]>--- tests/generic/1221 | 45 ++++++++++++++++++++++++ tests/generic/1221.out | 2 + tests/generic/711 | 2 + tests/xfs/1215 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1215.out | 13 +++++++ tests/xfs/789 | 2 +
Quoted 2 lines
Shouldn't the "xfs/537" (in subject) be xfs/789? I'll change that when I merge it.
No. generic/711 is forked to become generic/1221, and xfs/537 is forked to become xfs/1215. Maybe I should say that explicitly?
"Fork these tests to check the same things with exchange-range as they do for swapext, since the code porting swapext to commit-range has been dropped. generic/711 is forked to generic/1221, and xfs/537 is forked to xfs/1215.
"I was going to fork xfs/789 as well, but it turns out that generic/714 covers this sufficiently so for that one, we just strike fiexchange from the group tag."
--D
Quoted 213 lines
Thanks,
ZorroQuoted 208 lines
6 files changed, 151 insertions(+), 2 deletions(-) create mode 100755 tests/generic/1221 create mode 100644 tests/generic/1221.out create mode 100755 tests/xfs/1215 create mode 100644 tests/xfs/1215.outtests/generic/1221 new file +45
-0@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1221 +# +# Make sure that exchangerange won't touch a swap file. + +. ./common/preamble +_begin_fstest auto quick fiexchange + +# Override the default cleanup function. +_cleanup() +{ + cd / + test -e "$dir/a" && swapoff $dir/a + rm -r -f $tmp.* $dir +} + +# Import common functions. +. ./common/filter + +# real QA test starts here +_require_xfs_io_command exchangerange +_require_test + +dir=$TEST_DIR/test-$seq +mkdir -p $dir + +# Set up a fragmented swapfile and a dummy donor file. +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$here/src/punch-alternating $dir/a +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$MKSWAP_PROG $dir/a >> $seqres.full + +$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 32m -b 1m' $dir/b >> $seqres.full + +swapon $dir/a || _notrun 'failed to swapon' + +# Now try to exchangerange. +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a + +# success, all done +status=0 +exittests/generic/1221.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 1221 +exchangerange: Text file busytests/generic/711 +1
-1@@ -7,7 +7,7 @@ # Make sure that swapext won't touch a swap file. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()tests/xfs/1215 new file +89
-0@@ -0,0 +1,89 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1215 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# exchanging ranges between files +. ./common/preamble +_begin_fstest auto quick collapse fiexchange + +# Import common functions. +. ./common/filter +. ./common/inject + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_scratch_rmapbt +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "exchangerange" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Exchange extent forks" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +donorfile=${SCRATCH_MNT}/donorfile + +echo "Create \$donorfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((17 * bsize)) 0 $((17 * bsize))" $donorfile \ + >> $seqres.full + +# After the for loop the donor file will have the following extent layout +# | 0-4 | 5 | 6 | 7 | 8 | 9 | 10 | +echo "Fragment \$donorfile" +for i in $(seq 5 10); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done + +echo "Create \$srcfile having an extent of length 18 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((18 * bsize)) 0 $((18 * bsize))" $srcfile \ + >> $seqres.full + +echo "Fragment \$srcfile" +# After the for loop the src file will have the following extent layout +# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7-10 | +for i in $(seq 1 7); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$(_xfs_get_fsxattr nextents $donorfile) + +echo "Collect \$srcfile's extent count" +src_nr_exts=$(_xfs_get_fsxattr nextents $srcfile) + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Exchange \$srcfile's and \$donorfile's extent forks" +$XFS_IO_PROG -f -c "exchangerange $donorfile" $srcfile >> $seqres.full 2>&1 + +echo "Check for \$donorfile's extent count overflow" +nextents=$(_xfs_get_fsxattr nextents $donorfile) + +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$(_xfs_get_fsxattr nextents $srcfile) + +if (( $nextents == $donor_nr_exts )); then + echo "\$srcfile: Extent count overflow check failed" +fi + +# success, all done +status=0 +exittests/xfs/1215.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 1215 +* Exchange extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 18 blocks +Fragment $srcfile +Collect $donorfile's extent count +Collect $srcfile's extent count +Inject reduce_max_iextents error tag +Exchange $srcfile's and $donorfile's extent forks +Check for $donorfile's extent count overflow +Check for $srcfile's extent count overflowtests/xfs/789 +1
-1@@ -7,7 +7,7 @@ # Simple tests of the old xfs swapext ioctl . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()
Re: [PATCH 04/11] generic/711,xfs/537: actually fork these tests for exchange-range
Quoted 21 lines · Darrick J. Wong
Quoted 20 lines · Zorro Lang
Quoted 18 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Fork these tests to check the same things with exchange-range as they do for swapext, since the code porting swapext to commit-range has been dropped.
I was going to fork xfs/789 as well, but it turns out that generic/714 covers this sufficiently so for that one, we just strike fiexchange from the group tag.
Signed-off-by Darrick J. Wong <[email protected]>--- tests/generic/1221 | 45 ++++++++++++++++++++++++ tests/generic/1221.out | 2 + tests/generic/711 | 2 + tests/xfs/1215 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1215.out | 13 +++++++ tests/xfs/789 | 2 +
Quoted 5 lines
Quoted 2 lines
Shouldn't the "xfs/537" (in subject) be xfs/789? I'll change that when I merge it.
No. generic/711 is forked to become generic/1221, and xfs/537 is forked to become xfs/1215. Maybe I should say that explicitly?
OK, I'll revert my change, and add this explanation. Thanks!
Thanks,
Zorro
Quoted 226 lines
"Fork these tests to check the same things with exchange-range as they do for swapext, since the code porting swapext to commit-range has been dropped. generic/711 is forked to generic/1221, and xfs/537 is forked to xfs/1215.
"I was going to fork xfs/789 as well, but it turns out that generic/714 covers this sufficiently so for that one, we just strike fiexchange from the group tag."
--D
Quoted 213 lines
Thanks,
ZorroQuoted 208 lines
6 files changed, 151 insertions(+), 2 deletions(-) create mode 100755 tests/generic/1221 create mode 100644 tests/generic/1221.out create mode 100755 tests/xfs/1215 create mode 100644 tests/xfs/1215.outtests/generic/1221 new file +45
-0@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Oracle. All Rights Reserved. +# +# FS QA Test No. 1221 +# +# Make sure that exchangerange won't touch a swap file. + +. ./common/preamble +_begin_fstest auto quick fiexchange + +# Override the default cleanup function. +_cleanup() +{ + cd / + test -e "$dir/a" && swapoff $dir/a + rm -r -f $tmp.* $dir +} + +# Import common functions. +. ./common/filter + +# real QA test starts here +_require_xfs_io_command exchangerange +_require_test + +dir=$TEST_DIR/test-$seq +mkdir -p $dir + +# Set up a fragmented swapfile and a dummy donor file. +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$here/src/punch-alternating $dir/a +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 32m -b 1m' -c fsync $dir/a >> $seqres.full +$MKSWAP_PROG $dir/a >> $seqres.full + +$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 32m -b 1m' $dir/b >> $seqres.full + +swapon $dir/a || _notrun 'failed to swapon' + +# Now try to exchangerange. +$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a + +# success, all done +status=0 +exittests/generic/1221.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 1221 +exchangerange: Text file busytests/generic/711 +1
-1@@ -7,7 +7,7 @@ # Make sure that swapext won't touch a swap file. . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()tests/xfs/1215 new file +89
-0@@ -0,0 +1,89 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1215 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# exchanging ranges between files +. ./common/preamble +_begin_fstest auto quick collapse fiexchange + +# Import common functions. +. ./common/filter +. ./common/inject + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_scratch_rmapbt +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "exchangerange" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Exchange extent forks" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +donorfile=${SCRATCH_MNT}/donorfile + +echo "Create \$donorfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((17 * bsize)) 0 $((17 * bsize))" $donorfile \ + >> $seqres.full + +# After the for loop the donor file will have the following extent layout +# | 0-4 | 5 | 6 | 7 | 8 | 9 | 10 | +echo "Fragment \$donorfile" +for i in $(seq 5 10); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done + +echo "Create \$srcfile having an extent of length 18 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((18 * bsize)) 0 $((18 * bsize))" $srcfile \ + >> $seqres.full + +echo "Fragment \$srcfile" +# After the for loop the src file will have the following extent layout +# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7-10 | +for i in $(seq 1 7); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$(_xfs_get_fsxattr nextents $donorfile) + +echo "Collect \$srcfile's extent count" +src_nr_exts=$(_xfs_get_fsxattr nextents $srcfile) + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Exchange \$srcfile's and \$donorfile's extent forks" +$XFS_IO_PROG -f -c "exchangerange $donorfile" $srcfile >> $seqres.full 2>&1 + +echo "Check for \$donorfile's extent count overflow" +nextents=$(_xfs_get_fsxattr nextents $donorfile) + +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$(_xfs_get_fsxattr nextents $srcfile) + +if (( $nextents == $donor_nr_exts )); then + echo "\$srcfile: Extent count overflow check failed" +fi + +# success, all done +status=0 +exittests/xfs/1215.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 1215 +* Exchange extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 18 blocks +Fragment $srcfile +Collect $donorfile's extent count +Collect $srcfile's extent count +Inject reduce_max_iextents error tag +Exchange $srcfile's and $donorfile's extent forks +Check for $donorfile's extent count overflow +Check for $srcfile's extent count overflowtests/xfs/789 +1
-1@@ -7,7 +7,7 @@ # Simple tests of the old xfs swapext ioctl . ./common/preamble -_begin_fstest auto quick fiexchange swapext +_begin_fstest auto quick swapext # Override the default cleanup function. _cleanup()
PATCH 5/11 generic/717: remove obsolete check
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The final version of the EXCHANGERANGE ioctl has dropped the flag that enforced that the two files being operated upon were exactly the same length as was specified in the ioctl parameters. Remove this check since it's now defunct.
--- tests/generic/717 | 5 ----- tests/generic/717.out | 2 -- 2 files changed, 7 deletions(-)
tests/generic/717 +0 -5
@@ -77,11 +77,6 @@ $XFS_IO_PROG -c "exchangerange -d 0 -s $(( blksz * nrblks )) -l 37 $dir/b" $dir/ echo file2 unaligned EOF to file1 nowhere near EOF $XFS_IO_PROG -c "exchangerange -s 0 -d $(( blksz * nrblks )) -l 37 $dir/b" $dir/a -echo Files of unequal length -_pwrite_byte 0x58 $((blksz * nrblks)) $((blksz * 2)) $dir/a >> $seqres.full -_pwrite_byte 0x59 $((blksz * nrblks)) $blksz $dir/b >> $seqres.full -$XFS_IO_PROG -c "exchangerange $dir/b" $dir/a - echo Files on different filesystems _pwrite_byte 0x58 0 $((blksz * nrblks)) $SCRATCH_MNT/c >> $seqres.full $XFS_IO_PROG -c "exchangerange $SCRATCH_MNT/c" $dir/a
tests/generic/717.out +0 -2
@@ -23,8 +23,6 @@ file1 unaligned EOF to file2 nowhere near EOF exchangerange: Invalid argument file2 unaligned EOF to file1 nowhere near EOF exchangerange: Invalid argument -Files of unequal length -exchangerange: Bad address Files on different filesystems exchangerange: Invalid cross-device link Files on different mounts
PATCH 6/11 ltp/{fsstress,fsx}: make the exchangerange naming consistent
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
xchg_range/xchgrange -> exchangerange, since that's what the name has become.
--- ltp/fsstress.c | 24 ++++++++++++------------ ltp/fsx.c | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-)
ltp/fsstress.c +12 -12
@@ -143,7 +143,7 @@ typedef enum {OP_URING_WRITE ,OP_WRITE ,OP_WRITEV , -OP_XCHGRANGE , +OP_EXCHANGE_RANGE , OP_LAST } opty_t;
@@ -273,7 +273,7 @@ void uring_read_f(opnum_t, long);void uring_write_f (opnum_t ,long );void write_f (opnum_t ,long );void writev_f (opnum_t ,long ); -void xchgrange_f (opnum_t ,long ); +void exchangerange_f (opnum_t ,long );char *xattr_flag_to_string (int );
@@ -343,7 +343,7 @@ struct opdesc ops[OP_LAST] = { [OP_URING_WRITE] = {"uring_write", uring_write_f, 1, 1 }, [OP_WRITE] = {"write", write_f, 4, 1 }, [OP_WRITEV] = {"writev", writev_f, 4, 1 }, - [OP_XCHGRANGE ] = {"xchgrange" , xchgrange_f,2 ,1 }, + [OP_EXCHANGE_RANGE ]= {"exchangerange" , exchangerange_f,2 ,1 }, }, *ops_end;flist_t flist[FT_nft] = {
@@ -2604,7 +2604,7 @@ chown_f(opnum_t opno, long r)/* exchange some arbitrary range of f1 to f2...fn. */ void -xchgrange_f ( +exchangerange_f (opnum_t opno,long r) {
@@ -2634,7 +2634,7 @@ xchgrange_f(init_pathname (&fpath1);if (!get_fname (FT_REGm, r, &fpath1,NULL ,NULL , &v1)) {if (v1) -printf ("%d/%lld: xchgrange read - no filename\n" , +printf ("%d/%lld: exchangerange read - no filename\n" , procid, opno); goto out_fpath1; }
@@ -2642,7 +2642,7 @@ xchgrange_f(init_pathname (&fpath2);if (!get_fname (FT_REGm,random (), &fpath2,NULL ,NULL , &v2)) {if (v2) -printf ("%d/%lld: xchgrange write - no filename\n" , +printf ("%d/%lld: exchangerange write - no filename\n" , procid, opno); goto out_fpath2; }
@@ -2653,7 +2653,7 @@ xchgrange_f(check_cwd ();if (fd1 <0 ) {if (v1) -printf ("%d/%lld: xchgrange read - open %s failed %d\n" , +printf ("%d/%lld: exchangerange read - open %s failed %d\n" , procid, opno, fpath1.path, e); goto out_fpath2; }
@@ -2663,7 +2663,7 @@ xchgrange_f(check_cwd ();if (fd2 <0 ) {if (v2) -printf ("%d/%lld: xchgrange write - open %s failed %d\n" , +printf ("%d/%lld: exchangerange write - open %s failed %d\n" , procid, opno, fpath2.path, e); goto out_fd1; }
@@ -2671,7 +2671,7 @@ xchgrange_f(/* Get file stats */ if (fstat64 (fd1, &stat1) <0 ) {if (v1) -printf ("%d/%lld: xchgrange read - fstat64 %s failed %d\n" , +printf ("%d/%lld: exchangerange read - fstat64 %s failed %d\n" , procid, opno, fpath1.path, errno); goto out_fd2; }
@@ -2679,7 +2679,7 @@ xchgrange_f(if (fstat64 (fd2, &stat2) <0 ) {if (v2) -printf ("%d/%lld: xchgrange write - fstat64 %s failed %d\n" , +printf ("%d/%lld: exchangerange write - fstat64 %s failed %d\n" , procid, opno, fpath2.path, errno); goto out_fd2; }
@@ -2688,7 +2688,7 @@ xchgrange_f(if (stat1.st_size < (stat1.st_blksize *2 ) || stat2.st_size < (stat2.st_blksize *2 )) {if (v2) -printf ("%d/%lld: xchgrange - files are too small\n" , +printf ("%d/%lld: exchangerange - files are too small\n" , procid, opno); goto out_fd2; }
@@ -2745,7 +2745,7 @@ xchgrange_f( goto retry; }if (v1 || v2) { -printf ("%d/%lld: xchgrange %s%s [%lld,%lld] -> %s%s [%lld,%lld]" , +printf ("%d/%lld: exchangerange %s%s [%lld,%lld] -> %s%s [%lld,%lld]" , procid, opno, fpath1.path, inoinfo1, (long long )off1, (long long )len, fpath2.path, inoinfo2, (long long )off2, (long long )len);
ltp/fsx.c +12 -12
@@ -176,7 +176,7 @@ int check_file = 0; /* -X flag enables */int clone_range_calls =1 ;/* -J flag disables */ int dedupe_range_calls =1 ;/* -B flag disables */ int copy_range_calls =1 ;/* -E flag disables */ -int xchg_range_calls =1 ;/* -0 flag disables */ +int exchange_range_calls =1 ;/* -0 flag disables */ int integrity =0 ;/* -i flag */ int fsxgoodfd =0 ;int o_direct;/* -Z */
@@ -272,7 +272,7 @@ static const char *op_names[] = { [OP_DEDUPE_RANGE] = "dedupe_range", [OP_COPY_RANGE] = "copy_range", [OP_FSYNC] = "fsync", - [OP_EXCHANGE_RANGE] = "xchg_range", + [OP_EXCHANGE_RANGE] = "exchange_range", };static const char *op_name (int operation)
@@ -1393,7 +1393,7 @@ do_insert_range(unsigned offset, unsigned length)static __u64 swap_flags =0 ;int -test_xchg_range (void ) +test_exchange_range (void ) {struct xfs_exch_range fsr = { .file1_fd = fd,
@@ -1425,7 +1425,7 @@ test_xchg_range(void) }void -do_xchg_range (unsigned offset,unsigned length,unsigned dest) +do_exchange_range (unsigned offset,unsigned length,unsigned dest) {struct xfs_exch_range fsr = { .file1_fd = fd,
@@ -1473,7 +1473,7 @@ do_xchg_range(unsigned offset, unsigned length, unsigned dest)if (ioctl (fd,XFS_IOC_EXCHANGE_RANGE , &fsr) ==-1 ) {prt ("exchange range: 0x%x to 0x%x at 0x%x\n" , offset, offset + length, dest); -prterr ("do_xchg_range: XFS_IOC_EXCHANGE_RANGE" ); +prterr ("do_exchange_range: XFS_IOC_EXCHANGE_RANGE" );report_failure (161 ); goto out_free; }
@@ -1487,13 +1487,13 @@ do_xchg_range(unsigned offset, unsigned length, unsigned dest)#else int -test_xchg_range (void ) +test_exchange_range (void ) {return 0 ; }void -do_xchg_range (unsigned offset,unsigned length,unsigned dest) +do_exchange_range (unsigned offset,unsigned length,unsigned dest) {return ; }
@@ -2231,7 +2231,7 @@ test(void) }break ;case OP_EXCHANGE_RANGE : -if (!xchg_range_calls) { +if (!exchange_range_calls) {log5 (op, offset, size, offset2,FL_SKIPPED ); goto out; }
@@ -2330,7 +2330,7 @@ test(void) goto out; } -do_xchg_range (offset, size, offset2); +do_exchange_range (offset, size, offset2);break ;case OP_CLONE_RANGE :if (size ==0 ) {
@@ -2936,7 +2936,7 @@ main(int argc, char **argv) insert_range_calls =0 ;break ;case '0' : - xchg_range_calls =0 ; + exchange_range_calls =0 ;break ;case 'J' : clone_range_calls =0 ;
@@ -3199,8 +3199,8 @@ main(int argc, char **argv) dedupe_range_calls =test_dedupe_range ();if (copy_range_calls) copy_range_calls =test_copy_range (); -if (xchg_range_calls) - xchg_range_calls =test_xchg_range (); +if (exchange_range_calls) + exchange_range_calls =test_exchange_range ();while (keep_running ())if (!test ())
PATCH 7/11 misc: flip HAVE_XFS_IOC_EXCHANGE_RANGE logic
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
We only need to include src/fiexchange.h if the system's xfslibs package either doesn't define it or is so old that we want a newer definition. Invert the logic so that we only use src/fiexchange if we need the override.
--- configure.ac | 2 +- include/builddefs.in | 2 +- ltp/Makefile | 4 ++-- m4/package_xfslibs.m4 | 13 +++++++------ src/Makefile | 4 ++-- src/global.h | 2 +- src/vfs/Makefile | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-)
configure.ac +1 -1
@@ -70,7 +70,7 @@ AC_HAVE_SEEK_DATA AC_HAVE_BMV_OF_SHARED AC_HAVE_NFTW AC_HAVE_RLIMIT_NOFILE -AC_HAVE_XFS_IOC_EXCHANGE_RANGE +AC_NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE AC_HAVE_FICLONE AC_CHECK_FUNCS([renameat2])
include/builddefs.in +1 -1
@@ -72,7 +72,7 @@ HAVE_SEEK_DATA = @have_seek_data@ HAVE_NFTW = @have_nftw@ HAVE_BMV_OF_SHARED = @have_bmv_of_shared@ HAVE_RLIMIT_NOFILE = @have_rlimit_nofile@ -HAVE_XFS_IOC_EXCHANGE_RANGE = @have_xfs_ioc_exchange_range@ +NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE = @need_internal_xfs_ioc_exchange_range@ HAVE_FICLONE = @have_ficlone@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
ltp/Makefile +2 -2
@@ -36,8 +36,8 @@ ifeq ($(HAVE_COPY_FILE_RANGE),yes) LCFLAGS += -DHAVE_COPY_FILE_RANGE endif -ifeq ($(HAVE_XFS_IOC_EXCHANGE_RANGE),yes) -LCFLAGS += -DHAVE_XFS_IOC_EXCHANGE_RANGE +ifeq ($(NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE),yes) +LCFLAGS += -DNEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE endif default: depend $(TARGETS)
m4/package_xfslibs.m4 +7 -6
@@ -92,16 +92,17 @@ AC_DEFUN([AC_HAVE_BMV_OF_SHARED], AC_SUBST(have_bmv_of_shared) ]) -# Check if we have XFS_IOC_EXCHANGE_RANGE -AC_DEFUN([AC_HAVE_XFS_IOC_EXCHANGE_RANGE], - [ AC_MSG_CHECKING([for XFS_IOC_EXCHANGE_RANGE]) +# Check if we need to override the system XFS_IOC_EXCHANGE_RANGE +AC_DEFUN([AC_NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE], + [ AC_MSG_CHECKING([for new enough XFS_IOC_EXCHANGE_RANGE]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #define _GNU_SOURCE #include <xfs/xfs.h> ]], [[ struct xfs_exch_range obj; ioctl(-1, XFS_IOC_EXCHANGE_RANGE, &obj); - ]])],[have_xfs_ioc_exchange_range=yes - AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)]) - AC_SUBST(have_xfs_ioc_exchange_range) + ]])],[AC_MSG_RESULT(yes)], + [need_internal_xfs_ioc_exchange_range=yes + AC_MSG_RESULT(no)]) + AC_SUBST(need_internal_xfs_ioc_exchange_range) ])
src/Makefile +2 -2
@@ -99,8 +99,8 @@ ifeq ($(HAVE_FICLONE),yes) TARGETS += t_reflink_read_race endif -ifeq ($(HAVE_XFS_IOC_EXCHANGE_RANGE),yes) -LCFLAGS += -DHAVE_XFS_IOC_EXCHANGE_RANGE +ifeq ($(NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE),yes) +LCFLAGS += -DNEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE endif CFILES = $(TARGETS:=.c)
src/global.h +1 -1
@@ -171,7 +171,7 @@#include <sys/mman.h> #endif -#ifndef HAVE_XFS_IOC_EXCHANGE_RANGE +#ifdef NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE # include "fiexchange.h" #endif
src/vfs/Makefile +2 -2
@@ -19,8 +19,8 @@ ifeq ($(HAVE_URING), true) LLDLIBS += -luring endif -ifeq ($(HAVE_XFS_IOC_EXCHANGE_RANGE),yes) -LCFLAGS += -DHAVE_XFS_IOC_EXCHANGE_RANGE +ifeq ($(NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE),yes) +LCFLAGS += -DNEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE endif default: depend $(TARGETS)
PATCH 8/11 src/fiexchange.h: update XFS_IOC_EXCHANGE_RANGE definitions
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Update to use our new file content exchange ioctl definitions.
--- ltp/fsstress.c | 10 +----- ltp/fsx.c | 19 ++--------- m4/package_xfslibs.m4 | 2 + src/fiexchange.h | 84 ++++++++++++------------------------------------- src/global.h | 10 ++++++ src/xfsfind.c | 1 - tests/generic/724 | 2 + tests/xfs/791 | 2 + 8 files changed, 37 insertions(+), 93 deletions(-)
ltp/fsstress.c +1 -9
@@ -2609,8 +2609,7 @@ exchangerange_f( long r) {#ifdef XFS_IOC_EXCHANGE_RANGE -struct xfs_exch_range fxr = {0 }; -static __u64 swap_flags =0 ; +struct xfs_exchange_range fxr = {0 };struct pathname fpath1;struct pathname fpath2;struct stat64 stat1;
@@ -2734,16 +2733,9 @@ exchangerange_f( fxr.file1_offset = off1; fxr.length = len; fxr.file2_offset = off2; - fxr.flags = swap_flags; -retry: ret =ioctl (fd2,XFS_IOC_EXCHANGE_RANGE , &fxr); e = ret <0 ? errno :0 ; -if (e ==EOPNOTSUPP && !(swap_flags &XFS_EXCH_RANGE_NONATOMIC )) { - swap_flags =XFS_EXCH_RANGE_NONATOMIC ; - fxr.flags |= swap_flags; - goto retry; - }if (v1 || v2) { printf("%d/%lld: exchangerange %s%s [%lld,%lld] -> %s%s [%lld,%lld]", procid, opno,
ltp/fsx.c +3 -16
@@ -1390,29 +1390,17 @@ do_insert_range(unsigned offset, unsigned length)#endif #ifdef XFS_IOC_EXCHANGE_RANGE -static __u64 swap_flags =0 ; -int test_exchange_range (void ) { -struct xfs_exch_range fsr = { +struct xfs_exchange_range fsr = { .file1_fd = fd, - .flags =XFS_EXCH_RANGE_DRY_RUN | swap_flags, + .flags =XFS_EXCHANGE_RANGE_DRY_RUN , };int ret, e; -retry: ret =ioctl (fd,XFS_IOC_EXCHANGE_RANGE , &fsr); e = ret <0 ? errno :0 ; -if (e ==EOPNOTSUPP && !(swap_flags &XFS_EXCH_RANGE_NONATOMIC )) { -/* -* If the call fails with atomic mode, try again with non -* atomic mode. -*/ - swap_flags =XFS_EXCH_RANGE_NONATOMIC ; - fsr.flags |= swap_flags; - goto retry; - }if (e ==EOPNOTSUPP || errno ==ENOTTY ) {if (!quiet) fprintf(stderr,
@@ -1427,12 +1415,11 @@ test_exchange_range(void)void do_exchange_range (unsigned offset,unsigned length,unsigned dest) { -struct xfs_exch_range fsr = { +struct xfs_exchange_range fsr = { .file1_fd = fd, .file1_offset = offset, .file2_offset = dest, .length = length, - .flags = swap_flags, };void *p;
m4/package_xfslibs.m4 +1 -1
@@ -99,7 +99,7 @@ AC_DEFUN([AC_NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE], #define _GNU_SOURCE #include <xfs/xfs.h> ]], [[ - struct xfs_exch_range obj; + struct xfs_exchange_range obj; ioctl(-1, XFS_IOC_EXCHANGE_RANGE, &obj); ]])],[AC_MSG_RESULT(yes)], [need_internal_xfs_ioc_exchange_range=yes
src/fiexchange.h +20 -64
106 lines not on this page · raw message
src/global.h +10 -0
@@ -9,10 +9,20 @@#include <config.h> +#ifdef NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE +/* Override struct xfs_exchange_range in xfslibs */ +# define xfs_exchange_range sys_xfs_exchange_range +#endif +#ifdef HAVE_XFS_XFS_H #include <xfs/xfs.h> #endif +#ifdef NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE +# undef xfs_exchange_range +# undef XFS_IOC_EXCHANGE_RANGE +#endif +#ifdef HAVE_XFS_LIBXFS_H #include <xfs/libxfs.h> #endif
src/xfsfind.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <ftw.h> #include <linux/fs.h> -#include <xfs/xfs.h> #include "global.h"
tests/generic/724 +1 -1
@@ -5,7 +5,7 @@ # FS QA Test No. 724 # # Test scatter-gather atomic file writes. We create a temporary file, write -# sparsely to it, then use XFS_EXCHRANGE_FILE1_WRITTEN flag to swap +# sparsely to it, then use XFS_EXCHANGE_RANGE_FILE1_WRITTEN flag to swap # atomicallly only the ranges that we wrote. . ./common/preamble
tests/xfs/791 +1 -1
@@ -5,7 +5,7 @@ # FS QA Test No. 791 # # Test scatter-gather atomic file writes. We create a temporary file, write -# sparsely to it, then use XFS_EXCHRANGE_FILE1_WRITTEN flag to swap +# sparsely to it, then use XFS_EXCHANGE_RANGE_FILE1_WRITTEN flag to swap # atomicallly only the ranges that we wrote. Inject an error so that we can # test that log recovery finishes the swap.
PATCH 9/11 xfs/122: fix for exchrange conversion
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Fix this test for the swapext -> exchrange conversion.
--- tests/xfs/122.out | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/xfs/122.out +3 -3
@@ -92,7 +92,7 @@ sizeof(struct xfs_disk_dquot) = 104 sizeof(struct xfs_dqblk) = 136 sizeof(struct xfs_dsb) = 264 sizeof(struct xfs_dsymlink_hdr) = 56 -sizeof(struct xfs_exch_range) = 120 +sizeof(struct xfs_exchange_range) = 40 sizeof(struct xfs_extent_data) = 24 sizeof(struct xfs_extent_data_info) = 32 sizeof(struct xfs_fs_eofblocks) = 128
@@ -121,9 +121,9 @@ sizeof(struct xfs_rud_log_format) = 16 sizeof(struct xfs_rui_log_format) = 16 sizeof(struct xfs_scrub_metadata) = 64 sizeof(struct xfs_swap_extent) = 64 -sizeof(struct xfs_sxd_log_format) = 16 -sizeof(struct xfs_sxi_log_format) = 80 sizeof(struct xfs_unmount_log_format) = 8 +sizeof(struct xfs_xmd_log_format) = 16 +sizeof(struct xfs_xmi_log_format) = 88 sizeof(union xfs_rtword_raw) = 4 sizeof(union xfs_suminfo_raw) = 4 sizeof(xfs_agf_t) = 224
PATCH 10/11 xfs/206: screen out exchange-range from golden output
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Fix this so that exchange-range doesn't trigger test failures.
--- tests/xfs/206 | 1 + 1 file changed, 1 insertion(+)
tests/xfs/206 +1 -0
@@ -64,6 +64,7 @@ mkfs_filter() -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \ -e "s/, lazy-count=[0-9]//" \ -e "/.*crc=/d" \ + -e "/exchange=/d" \ -e "/^Default configuration/d" }
PATCH 11/11 exchangerange: make sure that we don't swap unwritten extents unless they're part of a rt extent
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
By default, the FILE1_WRITTEN flag for the EXCHANGERANGE ioctl isn't supposed to touch anything except for written extents. In other words, it shouldn't exchange delalloc reservations, unwritten preallocations, or holes. The XFS implementation flushes dirty pagecache to disk so there should never be delalloc reservations running through the exchangerange machinery, but there can be unwritten extents.
Hence, write a test to make sure that unwritten extents don't get moved around. This test opts itself out for realtime filesystems where the allocation unit is larger than 1 fsblock because xfs has to move full allocation units, and that requires exchanging of partially written rt extents.
--- tests/xfs/1213 | 73 ++++++++++++++++ tests/xfs/1213.out | 2 tests/xfs/1214 | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1214.out | 2 4 files changed, 309 insertions(+) create mode 100755 tests/xfs/1213 create mode 100644 tests/xfs/1213.out create mode 100755 tests/xfs/1214 create mode 100644 tests/xfs/1214.out
tests/xfs/1213 new file +73 -0
@@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1213 +# +# Make sure that the XFS_EXCHANGE_RANGE_FILE1_WRITTEN actually skips holes and +# unwritten extents on the data device and the rt device when the rextsize +# is 1 fsblock. +# +. ./common/preamble +_begin_fstest auto fiexchange + +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_require_xfs_io_command "falloc" +_require_xfs_io_command exchangerange +_require_scratch + +_scratch_mkfs >> $seqres.full +_scratch_mount + +# This test doesn't deal with the unwritten extents that must be created when +# the realtime file allocation unit is larger than the fs blocksize. +file_blksz=$(_get_file_block_size $SCRATCH_MNT) +fs_blksz=$(_get_block_size $SCRATCH_MNT) +test "$file_blksz" -eq "$fs_blksz" || \ + _notrun "test requires file alloc unit ($file_blksz) == fs block size ($fs_blksz)" + +swap_and_check_contents() { + local a="$1" + local b="$2" + local tag="$3" + + local a_md5_before=$(md5sum $a | awk '{print $1}') + local b_md5_before=$(md5sum $b | awk '{print $1}') + + # Test exchangerange. -w means skip holes in /b + echo "swap $tag" >> $seqres.full + $XFS_IO_PROG -c fsync -c 'bmap -elpvvvv' $a $b >> $seqres.full + $XFS_IO_PROG -c "exchangerange -f -w $b" $a >> $seqres.full + $XFS_IO_PROG -c 'bmap -elpvvvv' $a $b >> $seqres.full + _scratch_cycle_mount + + local a_md5_after=$(md5sum $a | awk '{print $1}') + local b_md5_after=$(md5sum $b | awk '{print $1}') + + test "$a_md5_before" != "$a_md5_after" && \ + echo "$a: md5 $a_md5_before -> $a_md5_after in $tag" + + test "$b_md5_before" != "$b_md5_after" && \ + echo "$b: md5 $b_md5_before -> $b_md5_after in $tag" +} + +# plain preallocations on the data device +$XFS_IO_PROG -c 'extsize 0' $SCRATCH_MNT +_pwrite_byte 0x58 0 1m $SCRATCH_MNT/dar >> $seqres.full +$XFS_IO_PROG -f -c 'truncate 1m' -c "falloc 640k 64k" $SCRATCH_MNT/dbr +swap_and_check_contents $SCRATCH_MNT/dar $SCRATCH_MNT/dbr "plain prealloc" + +# extent size hints on the data device +$XFS_IO_PROG -c 'extsize 1m' $SCRATCH_MNT +_pwrite_byte 0x58 0 1m $SCRATCH_MNT/dae >> $seqres.full +$XFS_IO_PROG -f -c 'truncate 1m' -c "falloc 640k 64k" $SCRATCH_MNT/dbe +swap_and_check_contents $SCRATCH_MNT/dae $SCRATCH_MNT/dbe "data dev extsize prealloc" + +echo Silence is golden +status=0 +exit
tests/xfs/1213.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1213 +Silence is golden
tests/xfs/1214 new file +232 -0
232 lines not on this page · raw message
tests/xfs/1214.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1214 +Silence is golden
PATCH 3/6 fstests: adjust tests for xfs parent pointers
In reply to Darrick J. WongHi all,
These are the test adjustments that are required for parent pointers. There's also a few new tests to ensure that the GETPARENTS ioctl (and
file extent can cross an rtgroup boundary.
The best advantage for rtgroups will become evident later when we get to adding rmap and reflink to the realtime volume, since the geometry constraints are the same for rt groups and AGs. Hence we can reuse all that code directly.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=pptrs
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=pptrs
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=pptrs
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=pptrs
---
Commits in this patchset:
* generic: test recovery of extended attribute updates
* xfs/206: filter out the parent= status from mkfs
* xfs/122: update for parent pointers
* populate: create hardlinks for parent pointers
* xfs/021: adapt golden output files for parent pointers
* xfs/{018,191,288}: disable parent pointers for these tests
* xfs/306: fix formatting failures with parent pointers
* common: add helpers for parent pointer tests
* xfs: add parent pointer test
* xfs: add multi link parent pointer test
* xfs: add parent pointer inject test
---
common/parent | 209 +++++++++
common/populate | 42 ++
common/rc | 7
common/xfs | 28 +
doc/group-names.txt | 1
src/popdir.pl | 11
tests/generic/1834 | 93 ++++
tests/generic/1834.out | 2
tests/xfs/018 | 4
tests/xfs/021 | 15 +
tests/xfs/021.cfg | 1
tests/xfs/021.out.default | 0
tests/xfs/021.out.parent | 64 +++
tests/xfs/122.out | 4
tests/xfs/1851 | 116 +++++
tests/xfs/1851.out | 69 +++
tests/xfs/1852 | 69 +++
tests/xfs/1852.out | 1002 +++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/1853 | 85 ++++
tests/xfs/1853.out | 14 +
tests/xfs/191 | 3
tests/xfs/206 | 1
tests/xfs/288 | 4
tests/xfs/306 | 9
24 files changed, 1846 insertions(+), 7 deletions(-)
create mode 100644 common/parent
create mode 100755 tests/generic/1834
create mode 100644 tests/generic/1834.out
create mode 100644 tests/xfs/021.cfg
rename tests/xfs/{021.out => 021.out.default} (100%)
create mode 100644 tests/xfs/021.out.parent
create mode 100755 tests/xfs/1851
create mode 100644 tests/xfs/1851.out
create mode 100755 tests/xfs/1852
create mode 100644 tests/xfs/1852.out
create mode 100755 tests/xfs/1853
create mode 100644 tests/xfs/1853.outPATCH 1/11 generic: test recovery of extended attribute updates
From: Darrick J. Wong <[email protected]>
Fork generic/475 to test recovery of extended attribute modifications and log recovery.
--- tests/generic/1834 | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1834.out | 2 + 2 files changed, 95 insertions(+) create mode 100755 tests/generic/1834 create mode 100644 tests/generic/1834.out
tests/generic/1834 new file +93 -0
@@ -0,0 +1,93 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2024 Oracle, Inc. All Rights Reserved. +# +# FS QA Test No. 1834 +# +# Test log recovery with repeated (simulated) disk failures. We kick +# off fsstress on the scratch fs to exercise extended attribute operations, +# then switch out the underlying device with dm-error to see what happens when +# the disk goes down. Having taken down the fs in this manner, remount it and +# repeat. +# +. ./common/preamble +_begin_fstest shutdown auto log metadata eio recoveryloop attr + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* + $KILLALL_PROG -9 fsstress > /dev/null 2>&1 + _dmerror_unmount + _dmerror_cleanup +} + +# Import common functions. +. ./common/dmerror + +# Modify as appropriate. +_supported_fs generic + +_require_scratch +_require_dm_target error +_require_command "$KILLALL_PROG" "killall" + +echo "Silence is golden." + +_scratch_mkfs >> $seqres.full 2>&1 +_require_metadata_journaling $SCRATCH_DEV +_dmerror_init +_dmerror_mount + +args=('-z' '-S' 'c') + +# Do some directory tree modifications, but the bulk of this is geared towards +# exercising the xattr code, especially attr_set which can do up to 10k values. +for verb in unlink rmdir; do + args+=('-f' "${verb}=50") +done +for verb in creat mkdir; do + args+=('-f' "${verb}=2") +done +for verb in getfattr listfattr; do + args+=('-f' "${verb}=3") +done +for verb in attr_remove removefattr; do + args+=('-f' "${verb}=4") +done +args+=('-f' "setfattr=20") +args+=('-f' "attr_set=60") # sets larger xattrs + +while _soak_loop_running $((50 * TIME_FACTOR)); do + ($FSSTRESS_PROG "${args[@]}" $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p $((LOAD_FACTOR * 4)) >> $seqres.full &) \ + > /dev/null 2>&1 + + # purposely include 0 second sleeps to test shutdown immediately after + # recovery + sleep $((RANDOM % 3)) + + # This test aims to simulate sudden disk failure, which means that we + # do not want to quiesce the filesystem or otherwise give it a chance + # to flush its logs. Therefore we want to call dmsetup with the + # --nolockfs parameter; to make this happen we must call the load + # error table helper *without* 'lockfs'. + _dmerror_load_error_table + + ps -e | grep fsstress > /dev/null 2>&1 + while [ $? -eq 0 ]; do + $KILLALL_PROG -9 fsstress > /dev/null 2>&1 + wait > /dev/null 2>&1 + ps -e | grep fsstress > /dev/null 2>&1 + done + + # Mount again to replay log after loading working table, so we have a + # consistent XFS after test. + _dmerror_unmount || _fail "unmount failed" + _dmerror_load_working_table + _dmerror_mount || _fail "mount failed" +done + +# success, all done +status=0 +exit
tests/generic/1834.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1834 +Silence is golden.
PATCH 2/11 xfs/206: filter out the parent= status from mkfs
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Filter out the parent pointer bits from the mkfs output so that we don't cause a regression in this test.
--- tests/xfs/206 | 1 + 1 file changed, 1 insertion(+)
tests/xfs/206 +1 -0
@@ -65,6 +65,7 @@ mkfs_filter() -e "s/, lazy-count=[0-9]//" \ -e "/.*crc=/d" \ -e "/exchange=/d" \ + -e 's/, parent=[01]//' \ -e "/^Default configuration/d" }
PATCH 3/11 xfs/122: update for parent pointers
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Update test for parent pointers.
--- tests/xfs/122.out | 4 ++++ 1 file changed, 4 insertions(+)
tests/xfs/122.out +4 -0
@@ -100,6 +100,9 @@ sizeof(struct xfs_fsop_ag_resblks) = 64 sizeof(struct xfs_fsop_geom) = 256 sizeof(struct xfs_fsop_geom_v1) = 112 sizeof(struct xfs_fsop_geom_v4) = 112 +sizeof(struct xfs_getparents) = 40 +sizeof(struct xfs_getparents_by_handle) = 64 +sizeof(struct xfs_getparents_rec) = 32 sizeof(struct xfs_icreate_log) = 28 sizeof(struct xfs_inode_log_format) = 56 sizeof(struct xfs_inode_log_format_32) = 52
@@ -109,6 +112,7 @@ sizeof(struct xfs_legacy_timestamp) = 8 sizeof(struct xfs_log_dinode) = 176 sizeof(struct xfs_log_legacy_timestamp) = 8 sizeof(struct xfs_map_extent) = 32 +sizeof(struct xfs_parent_rec) = 12 sizeof(struct xfs_phys_extent) = 16 sizeof(struct xfs_refcount_key) = 4 sizeof(struct xfs_refcount_rec) = 12
PATCH 4/11 populate: create hardlinks for parent pointers
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Create some hardlinked files so that we can exercise parent pointers.
--- common/populate | 42 ++++++++++++++++++++++++++++++++++++++++++ src/popdir.pl | 11 +++++++++++ 2 files changed, 53 insertions(+)
common/populate +42 -0
@@ -464,6 +464,48 @@ _scratch_xfs_populate() { cp --reflink=always "${SCRATCH_MNT}/REFCOUNTBT" "${SCRATCH_MNT}/REFCOUNTBT2" fi + # Parent pointers + is_pptr="$(_xfs_has_feature "$SCRATCH_MNT" parent -v)" + if [ $is_pptr -gt 0 ]; then + echo "+ parent pointers" + + # Create a couple of parent pointers + __populate_create_dir "${SCRATCH_MNT}/PPTRS" 1 '' \ + --hardlink --format "two_%d" + + # Create one xattr leaf block of parent pointers + nr="$((blksz * 2 / 16))" + __populate_create_dir "${SCRATCH_MNT}/PPTRS" ${nr} '' \ + --hardlink --format "many%04d" + + # Create multiple xattr leaf blocks of large parent pointers + nr="$((blksz * 16 / 16))" + __populate_create_dir "${SCRATCH_MNT}/PPTRS" ${nr} '' \ + --hardlink --format "y%0254d" + + # Create multiple paths to a file + local moof="${SCRATCH_MNT}/PPTRS/moofile" + touch "${moof}" + for ((i = 0; i < 4; i++)); do + mkdir -p "${SCRATCH_MNT}/PPTRS/SUB${i}" + ln "${moof}" "${SCRATCH_MNT}/PPTRS/SUB${i}/moofile" + done + + # Create parent pointers of various lengths + touch "${SCRATCH_MNT}/PPTRS/vlength" + local len_len + local tst + local fname + ln "${SCRATCH_MNT}/PPTRS/vlength" "${SCRATCH_MNT}/PPTRS/b" + for len in 32 64 96 128 160 192 224 250 255; do + len_len="${#len}" + tst="$(perl -e "print \"b\" x (${len} - (${len_len} + 1))")" + fname="v${tst}${len}" + ln "${SCRATCH_MNT}/PPTRS/vlength" \ + "${SCRATCH_MNT}/PPTRS/${fname}" + done + fi + # Copy some real files (xfs tests, I guess...) echo "+ real files" test $fill -ne 0 && __populate_fill_fs "${SCRATCH_MNT}" 5
src/popdir.pl +11 -0
@@ -17,6 +17,7 @@ GetOptions("start=i" => \$start, "dir=s" => \$dir, "remove!" => \$remove, "help!" => \$help, + "hardlink!" => \$hardlink, "verbose!" => \$verbose);
@@ -35,6 +36,7 @@ Options: --format=str printf formatting string for file name ("%08d") --verbose verbose output --help this help screen + --hardlink hardlink subsequent files to the first one created EOF exit(1) unless defined $help; # otherwise...
@@ -56,12 +58,21 @@ if ($file_pct < 0) { $file_pct = 100; } +if ($hardlink) { + $file_pct = 100; + $link_fname = sprintf($format, $start); +} + for ($i = $start; $i <= $end; $i += $incr) { $fname = sprintf($format, $i); if ($remove) { $verbose && print "rm $fname\n"; unlink($fname) or rmdir($fname) or die("unlink $fname"); + } elsif ($hardlink && $i > $start) { + # hardlink everything after the first file + $verbose && print "ln $link_fname $fname\n"; + link $link_fname, $fname; } elsif (($i % 100) < $file_pct) { # create a file $verbose && print "touch $fname\n";
PATCH 5/11 xfs/021: adapt golden output files for parent pointers
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Parent pointers change the xattr structure dramatically, so fix this test to handle them. For the most part we can get away with filtering out the parent pointer fields (which xfs_db decodes for us), but the namelen/valuelen/attr_filter fields still show through.
---
common/rc | 4 +++
tests/xfs/021 | 15 +++++++++--
tests/xfs/021.cfg | 1 +
tests/xfs/021.out.default | 0
tests/xfs/021.out.parent | 64 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 82 insertions(+), 2 deletions(-)
create mode 100644 tests/xfs/021.cfg
rename tests/xfs/{021.out => 021.out.default} (100%)
create mode 100644 tests/xfs/021.out.parentcommon/rc +4 -0
@@ -3472,6 +3472,8 @@ _get_os_name() _link_out_file_named() { + test -n "$seqfull" || _fail "need to set seqfull" + local features=$2 local suffix=$(FEATURES="$features" perl -e ' my %feathash;
@@ -3507,6 +3509,8 @@ _link_out_file() { local features + test -n "$seqfull" || _fail "need to set seqfull" + if [ $# -eq 0 ]; then features="$(_get_os_name),$FSTYP" if [ -n "$MOUNT_OPTIONS" ]; then
tests/xfs/021 +13 -2
@@ -67,6 +67,13 @@ _scratch_mkfs_xfs >/dev/null \ echo "*** mount FS" _scratch_mount +seqfull=$0 +if _xfs_has_feature $SCRATCH_MNT parent; then + _link_out_file "parent" +else + _link_out_file "" +fi + testfile=$SCRATCH_MNT/testfile echo "*** make test file 1"
@@ -108,7 +115,10 @@ _scratch_unmount >>$seqres.full 2>&1 \ echo "*** dump attributes (1)" _scratch_xfs_db -r -c "inode $inum_1" -c "print a.sfattr" | \ - sed -e '/secure = /d' | sed -e '/parent = /d' + perl -ne ' +/\.secure/ && next; +/\.parent/ && next; + print unless /^\d+:\[.*/;' echo "*** dump attributes (2)"
@@ -124,10 +134,11 @@ s/info.hdr/info/; /hdr.info.uuid/ && next; /hdr.info.lsn/ && next; /hdr.info.owner/ && next; +/\.parent/ && next; s/^(hdr.info.magic =) 0x3bee/\1 0xfbee/; s/^(hdr.firstused =) (\d+)/\1 FIRSTUSED/; s/^(hdr.freemap\[0-2] = \[base,size]).*/\1 [FREEMAP..]/; -s/^(entries\[0-2] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/; +s/^(entries\[0-[23]] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/; print unless /^\d+:\[.*/;' echo "*** done"
tests/xfs/021.cfg new file +1 -0
@@ -0,0 +1 @@ +parent: parent
tests/xfs/021.out.default renamed from tests/xfs/021.out +0 -0
tests/xfs/021.out.parent new file +64 -0
64 lines not on this page · raw message
PATCH 6/11 xfs/{018,191,288}: disable parent pointers for these tests
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
These tests depend heavily on the xattr formats created for new files. Parent pointers break those assumptions, so force parent pointers off.
--- common/xfs | 16 ++++++++++++++++ tests/xfs/018 | 4 ++++ tests/xfs/191 | 3 +++ tests/xfs/288 | 4 ++++ 4 files changed, 27 insertions(+)
common/xfs +16 -0
@@ -1847,3 +1847,19 @@ _require_xfs_nocrc() _notrun "v4 file systems not supported" _scratch_unmount } + +# Adjust MKFS_OPTIONS as necessary to avoid having parent pointers formatted +# onto the filesystem +_xfs_force_no_pptrs() +{ + # Nothing to do if parent pointers aren't supported by mkfs + $MKFS_XFS_PROG 2>&1 | grep -q parent=0 || return + + if echo "$MKFS_OPTIONS" | grep -q 'parent='; then + MKFS_OPTIONS="$(echo "$MKFS_OPTIONS" | \ + sed -e 's/parent=[01]/parent=0/g')" + return + fi + + MKFS_OPTIONS="$MKFS_OPTIONS -n parent=0" +}
tests/xfs/018 +4 -0
@@ -111,6 +111,10 @@ attr32l="X$attr32k" attr64k="$attr32k$attr32k" echo "*** mkfs" + +# Parent pointers change the xattr formats sufficiently to break this test. +# Disable parent pointers if mkfs supports it. +_xfs_force_no_pptrs _scratch_mkfs >/dev/null blk_sz=$(_scratch_xfs_get_sb_field blocksize)
tests/xfs/191 +3 -0
@@ -33,6 +33,9 @@ _fixed_by_kernel_commit 7be3bd8856fb "xfs: empty xattr leaf header blocks are no _fixed_by_kernel_commit e87021a2bc10 "xfs: use larger in-core attr firstused field and detect overflow" _fixed_by_git_commit xfsprogs f50d3462c654 "xfs_repair: ignore empty xattr leaf blocks" +# Parent pointers change the xattr formats sufficiently to break this test. +# Disable parent pointers if mkfs supports it. +_xfs_force_no_pptrs _scratch_mkfs_xfs | _filter_mkfs >$seqres.full 2>$tmp.mkfs cat $tmp.mkfs >> $seqres.full source $tmp.mkfs
tests/xfs/288 +4 -0
@@ -19,6 +19,10 @@ _supported_fs xfs _require_scratch _require_attrs +# Parent pointers change the xattr formats sufficiently to break this test. +# Disable parent pointers if mkfs supports it. +_xfs_force_no_pptrs + # get block size ($dbsize) from the mkfs output _scratch_mkfs_xfs 2>/dev/null | _filter_mkfs 2>$tmp.mkfs >/dev/null . $tmp.mkfs
PATCH 7/11 xfs/306: fix formatting failures with parent pointers
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The parent pointers feature isn't supported on tiny 20MB filesystems because the larger directory transactions result in larger minimum log sizes, particularly with nrext64 enabled:
** mkfs failed with extra mkfs options added to " -m rmapbt=0, -i nrext64=1, -n parent=1," by test 306 ** ** attempting to mkfs using only test 306 options: -d size=20m -n size=64k **
max log size 5108 smaller than min log size 5310, filesystem is too small
We don't support 20M filesystems anymore, so bump the filesystem size up to 100M and skip this test if we can't actually format the filesystem. Convert the open-coded punch-alternating logic into a call to that program to reduce execve overhead, which more than makes up having to write 5x as much data to fragment the free space.
--- tests/xfs/306 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tests/xfs/306 +4 -5
@@ -23,6 +23,7 @@ _supported_fs xfs _require_scratch_nocheck # check complains about single AG fs _require_xfs_io_command "fpunch" _require_command $UUIDGEN_PROG uuidgen +_require_test_program "punch-alternating" # Disable the scratch rt device to avoid test failures relating to the rt # bitmap consuming all the free space in our small data device.
@@ -30,7 +31,8 @@ unset SCRATCH_RTDEV # Create a small fs with a large directory block size. We want to fill up the fs # quickly and then create multi-fsb dirblocks over fragmented free space. -_scratch_mkfs_xfs -d size=20m -n size=64k >> $seqres.full 2>&1 +_scratch_mkfs_xfs -d size=100m -n size=64k >> $seqres.full 2>&1 || \ + _notrun 'could not format tiny scratch fs' _scratch_mount # Fill a source directory with many largish-named files. 1k uuid-named entries
@@ -49,10 +51,7 @@ done $XFS_IO_PROG -xc "resblks 16" $SCRATCH_MNT >> $seqres.full 2>&1 dd if=/dev/zero of=$SCRATCH_MNT/file bs=4k >> $seqres.full 2>&1 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/file >> $seqres.full 2>&1 -size=`_get_filesize $SCRATCH_MNT/file` -for i in $(seq 0 8192 $size); do - $XFS_IO_PROG -c "fpunch $i 4k" $SCRATCH_MNT/file >> $seqres.full 2>&1 -done +$here/src/punch-alternating $SCRATCH_MNT/file # Replicate the src dir several times into fragmented free space. After one or # two dirs, we should have nothing but non-contiguous directory blocks.
PATCH 8/11 common: add helpers for parent pointer tests
In reply to Darrick J. WongFrom: Allison Henderson <[email protected]>
Add helper functions in common/parent to parse and verify parent pointers. Also add functions to check that mkfs, kernel, and xfs_io support parent pointers.
[djwong: add license and copyright, dont _fail tests immediately, make
sure the pptr-generated paths match the dir-generated paths]
--- common/parent | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/rc | 3 + common/xfs | 12 +++ 3 files changed, 224 insertions(+) create mode 100644 common/parent
common/parent new file +209 -0
@@ -0,0 +1,209 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2024 Oracle and/or its affiliates. All Rights Reserved. +# +# Parent pointer common functions +# + +# +# parse_parent_pointer parents parent_inode parent_pointer_name +# +# Given a list of parent pointers, find the record that matches +# the given inode and filename +# +# inputs: +# parents : A list of parent pointers in the format of: +# inode/generation/name_length/name +# parent_inode : The parent inode to search for +# parent_name : The parent name to search for +# +# outputs: +# PPINO : Parent pointer inode +# PPGEN : Parent pointer generation +# PPNAME : Parent pointer name +# PPNAME_LEN : Parent pointer name length +# +_xfs_parse_parent_pointer() +{ + local parents=$1 + local pino=$2 + local parent_pointer_name=$3 + + local found=0 + + # Find the entry that has the same inode as the parent + # and parse out the entry info + while IFS=':' read PPINO PPGEN PPNAME_LEN PPNAME; do + if [ "$PPINO" != "$pino" ]; then + continue + fi + + if [ "$PPNAME" != "$parent_pointer_name" ]; then + continue + fi + + found=1 + break + done <<< $(echo "$parents") + + # Check to see if we found anything + # We do not fail the test because we also use this + # routine to verify when parent pointers should + # be removed or updated (ie a rename or a move + # operation changes your parent pointer) + if [ $found -eq "0" ]; then + return 1 + fi + + # Verify the parent pointer name length is correct + if [ "$PPNAME_LEN" -ne "${#parent_pointer_name}" ] + then + echo "*** Bad parent pointer:"\ + "name:$PPNAME, namelen:$PPNAME_LEN" + fi + + #return sucess + return 0 +} + +# +# _xfs_verify_parent parent_path parent_pointer_name child_path +# +# Verify that the given child path lists the given parent as a parent pointer +# and that the parent pointer name matches the given name +# +# Examples: +# +# #simple example +# mkdir testfolder1 +# touch testfolder1/file1 +# verify_parent testfolder1 file1 testfolder1/file1 +# +# # In this above example, we want to verify that "testfolder1" +# # appears as a parent pointer of "testfolder1/file1". Additionally +# # we verify that the name record of the parent pointer is "file1" +# +# +# #hardlink example +# mkdir testfolder1 +# mkdir testfolder2 +# touch testfolder1/file1 +# ln testfolder1/file1 testfolder2/file1_ln +# verify_parent testfolder2 file1_ln testfolder1/file1 +# +# # In this above example, we want to verify that "testfolder2" +# # appears as a parent pointer of "testfolder1/file1". Additionally +# # we verify that the name record of the parent pointer is "file1_ln" +# +_xfs_verify_parent() +{ + local parent_path=$1 + local parent_pointer_name=$2 + local child_path=$3 + + local parent_ppath="$parent_path/$parent_pointer_name" + + # Verify parent exists + if [ ! -d $SCRATCH_MNT/$parent_path ]; then + echo "$SCRATCH_MNT/$parent_path not found" + else + echo "*** $parent_path OK" + fi + + # Verify child exists + if [ ! -f $SCRATCH_MNT/$child_path ]; then + echo "$SCRATCH_MNT/$child_path not found" + else + echo "*** $child_path OK" + fi + + # Verify the parent pointer name exists as a child of the parent + if [ ! -f $SCRATCH_MNT/$parent_ppath ]; then + echo "$SCRATCH_MNT/$parent_ppath not found" + else + echo "*** $parent_ppath OK" + fi + + # Get the inodes of both parent and child + pino="$(stat -c '%i' $SCRATCH_MNT/$parent_path)" + cino="$(stat -c '%i' $SCRATCH_MNT/$child_path)" + + # Get all the parent pointers of the child + parents=($($XFS_IO_PROG -x -c \ + "parent -s -i $pino -n $parent_pointer_name" $SCRATCH_MNT/$child_path)) + if [[ $? != 0 ]]; then + echo "No parent pointers found for $child_path" + fi + + # Parse parent pointer output. + # This sets PPINO PPGEN PPNAME PPNAME_LEN + _xfs_parse_parent_pointer $parents $pino $parent_pointer_name + + # If we didnt find one, bail out + if [ $? -ne 0 ]; then + echo "No parent pointer record found for $parent_path"\ + "in $child_path" + fi + + # Verify the inode generated by the parent pointer name is + # the same as the child inode + pppino="$(stat -c '%i' $SCRATCH_MNT/$parent_ppath)" + if [ $cino -ne $pppino ] + then + echo "Bad parent pointer name value for $child_path."\ + "$SCRATCH_MNT/$parent_ppath belongs to inode $PPPINO,"\ + "but should be $cino" + fi + + # Make sure path printing works by checking that the paths returned + # all point to the same inode. + local tgt="$SCRATCH_MNT/$child_path" + $XFS_IO_PROG -x -c 'parent -p' "$tgt" | while read pptr_path; do + test "$tgt" -ef "$pptr_path" || \ + echo "$tgt parent pointer $pptr_path should be the same file" + done + + echo "*** Verified parent pointer:"\ + "name:$PPNAME, namelen:$PPNAME_LEN" + echo "*** Parent pointer OK for child $child_path" +} + +# +# _xfs_verify_parent parent_pointer_name pino child_path +# +# Verify that the given child path contains no parent pointer entry +# for the given inode and file name +# +_xfs_verify_no_parent() +{ + local parent_pname=$1 + local pino=$2 + local child_path=$3 + + # Verify child exists + if [ ! -f $SCRATCH_MNT/$child_path ]; then + echo "$SCRATCH_MNT/$child_path not found" + else + echo "*** $child_path OK" + fi + + # Get all the parent pointers of the child + local parents=($($XFS_IO_PROG -x -c \ + "parent -s -i $pino -n $parent_pname" $SCRATCH_MNT/$child_path)) + if [[ $? != 0 ]]; then + return 0 + fi + + # Parse parent pointer output. + # This sets PPINO PPGEN PPNAME PPNAME_LEN + _xfs_parse_parent_pointer $parents $pino $parent_pname + + # If we didnt find one, return sucess + if [ $? -ne 0 ]; then + return 0 + fi + + echo "Parent pointer entry found where none should:"\ + "inode:$PPINO, gen:$PPGEN," + "name:$PPNAME, namelen:$PPNAME_LEN" +}
common/rc +3 -0
@@ -2742,6 +2742,9 @@ _require_xfs_io_command() echo $testio | grep -q "invalid option" && \ _notrun "xfs_io $command support is missing" ;; + "parent") + testio=`$XFS_IO_PROG -x -c "parent" $TEST_DIR 2>&1` + ;; "pwrite") # -N (RWF_NOWAIT) only works with direct vectored I/O writes local pwrite_opts=" "
common/xfs +12 -0
@@ -1863,3 +1863,15 @@ _xfs_force_no_pptrs() MKFS_OPTIONS="$MKFS_OPTIONS -n parent=0" } + +# this test requires the xfs parent pointers feature +# +_require_xfs_parent() +{ + _scratch_mkfs_xfs_supported -n parent > /dev/null 2>&1 \ + || _notrun "mkfs.xfs does not support parent pointers" + _scratch_mkfs_xfs -n parent > /dev/null 2>&1 + _try_scratch_mount >/dev/null 2>&1 \ + || _notrun "kernel does not support parent pointers" + _scratch_unmount +}
Re: [PATCH 08/11] common: add helpers for parent pointer tests
Looks good:
PATCH 9/11 xfs: add parent pointer test
In reply to Darrick J. WongFrom: Allison Henderson <[email protected]>
Add a test to verify basic parent pointers operations (create, move, link, unlink, rename, overwrite).
--- doc/group-names.txt | 1 tests/xfs/1851 | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1851.out | 69 ++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100755 tests/xfs/1851 create mode 100644 tests/xfs/1851.out
doc/group-names.txt +1 -0
@@ -83,6 +83,7 @@ nfs4_acl NFSv4 access control lists nonsamefs overlayfs layers on different filesystems online_repair online repair functionality tests other dumping ground, do not add more tests to this group +parent Parent pointer tests pattern specific IO pattern tests perms access control and permission checking pipe pipe functionality
tests/xfs/1851 new file +116 -0
116 lines not on this page · raw message
tests/xfs/1851.out new file +69 -0
69 lines not on this page · raw message
PATCH 10/11 xfs: add multi link parent pointer test
In reply to Darrick J. WongFrom: Allison Henderson <[email protected]>
Add a test to verify parent pointers while multiple links to a file are created and removed.
--- tests/xfs/1852 | 69 ++++ tests/xfs/1852.out | 1002 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1071 insertions(+) create mode 100755 tests/xfs/1852 create mode 100644 tests/xfs/1852.out
tests/xfs/1852 new file +69 -0
@@ -0,0 +1,69 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2024 Oracle and/or its affiliates. All Rights Reserved. +# +# FS QA Test No. 1852 +# +# multi link parent pointer test +# +. ./common/preamble +_begin_fstest auto quick parent + +# get standard environment, filters and checks +. ./common/parent + +# Modify as appropriate +_supported_fs xfs +_require_scratch +_require_xfs_sysfs debug/larp +_require_xfs_parent +_require_xfs_io_command "parent" + +# real QA test starts here + +# Create a directory tree using a protofile and +# make sure all inodes created have parent pointers + +protofile=$tmp.proto + +cat >$protofile <<EOF +DUMMY1 +0 0 +: root directory +d--777 3 1 +: a directory +testfolder1 d--755 3 1 +file1 ---755 3 1 /dev/null +: done +$ +EOF + +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqresres.full 2>&1 \ + || _fail "mkfs failed" +_check_scratch_fs + +_scratch_mount >>$seqres.full 2>&1 \ + || _fail "mount failed" + +testfolder1="testfolder1" +file1="file1" +file1_ln="file1_link" + +echo "" +# Multi link parent pointer test +NLINKS=100 +for (( j=0; j<$NLINKS; j++ )); do + ln $SCRATCH_MNT/$testfolder1/$file1 $SCRATCH_MNT/$testfolder1/$file1_ln.$j + _xfs_verify_parent "$testfolder1" "$file1_ln.$j" "$testfolder1/$file1" + _xfs_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1_ln.$j" +done +# Multi unlink parent pointer test +for (( j=$NLINKS-1; j<=0; j-- )); do + ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln.$j)" + rm $SCRATCH_MNT/$testfolder1/$file1_ln.$j + _xfs_verify_no_parent "$file1_ln.$j" "$ino" "$testfolder1/$file1" +done + +# success, all done +status=0 +exit
tests/xfs/1852.out new file +1002 -0
1,002 lines not on this page · raw message
PATCH 11/11 xfs: add parent pointer inject test
In reply to Darrick J. WongFrom: Allison Henderson <[email protected]>
Add a test to verify parent pointers after an error injection and log replay.
--- tests/xfs/1853 | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1853.out | 14 +++++++++ 2 files changed, 99 insertions(+) create mode 100755 tests/xfs/1853 create mode 100644 tests/xfs/1853.out
tests/xfs/1853 new file +85 -0
@@ -0,0 +1,85 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2024 Oracle and/or its affiliates. All Rights Reserved. +# +# FS QA Test No. 1853 +# +# parent pointer inject test +# +. ./common/preamble +_begin_fstest auto quick parent + +# get standard environment, filters and checks +. ./common/filter +. ./common/inject +. ./common/parent + +# Modify as appropriate +_supported_fs xfs +_require_scratch +_require_xfs_sysfs debug/larp +_require_xfs_io_error_injection "larp" +_require_xfs_parent +_require_xfs_io_command "parent" + +# real QA test starts here + +# Create a directory tree using a protofile and +# make sure all inodes created have parent pointers + +protofile=$tmp.proto + +cat >$protofile <<EOF +DUMMY1 +0 0 +: root directory +d--777 3 1 +: a directory +testfolder1 d--755 3 1 +$ +: back in the root +testfolder2 d--755 3 1 +: done +$ +EOF + +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \ + || _fail "mkfs failed" +_check_scratch_fs + +_scratch_mount >>$seqres.full 2>&1 \ + || _fail "mount failed" + +testfolder1="testfolder1" +testfolder2="testfolder2" +file4="file4" +file5="file5" + +echo "" + +# Create files +touch $SCRATCH_MNT/$testfolder1/$file4 +_xfs_verify_parent "$testfolder1" "$file4" "$testfolder1/$file4" + +# Inject error +_scratch_inject_error "larp" + +# Move files +mv $SCRATCH_MNT/$testfolder1/$file4 $SCRATCH_MNT/$testfolder2/$file5 2>&1 \ + | _filter_scratch + +# FS should be shut down, touch will fail +touch $SCRATCH_MNT/$testfolder2/$file5 2>&1 | _filter_scratch + +# Remount to replay log +_scratch_remount_dump_log >> $seqres.full + +# FS should be online, touch should succeed +touch $SCRATCH_MNT/$testfolder2/$file5 + +# Check files again +_xfs_verify_parent "$testfolder2" "$file5" "$testfolder2/$file5" + +# success, all done +status=0 +exit
tests/xfs/1853.out new file +14 -0
@@ -0,0 +1,14 @@ +QA output created by 1853 + +*** testfolder1 OK +*** testfolder1/file4 OK +*** testfolder1/file4 OK +*** Verified parent pointer: name:file4, namelen:5 +*** Parent pointer OK for child testfolder1/file4 +mv: cannot stat 'SCRATCH_MNT/testfolder1/file4': Input/output error +touch: cannot touch 'SCRATCH_MNT/testfolder2/file5': Input/output error +*** testfolder2 OK +*** testfolder2/file5 OK +*** testfolder2/file5 OK +*** Verified parent pointer: name:file5, namelen:5 +*** Parent pointer OK for child testfolder2/file5
PATCH 4/6 xfs: detect and correct directory tree structures
In reply to Darrick J. WongHi all,
Historically, checking the tree-ness of the directory tree structure has not been complete. Cycles of subdirectories break the tree properties, as do subdirectories with multiple parents. It's easy enough for DFS to detect problems as long as one of the participants is reachable from the root, but this technique cannot find unconnected cycles.
Directory parent pointers change that, because we can discover all of these problems from a simple walk from a subdirectory towards the root. For each child we start with, if the walk terminates without reaching the root, we know the path is disconnected and ought to be attached to the lost and found. If we find ourselves, we know this is a cycle and can delete an incoming edge. If we find multiple paths to the root, we know to delete an incoming edge.
Even better, once we've finished walking paths, we've identified the good ones and know which other path(s) to remove.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=scrub-directory-tree
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=scrub-directory-tree
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=scrub-directory-tree
---
Commits in this patchset:
* common/fuzzy: stress directory tree modifications with the dirtree tester
* scrub: test correction of directory tree corruptions
--- tests/xfs/1864 | 38 +++++++++++++ tests/xfs/1864.out | 2 + tests/xfs/1865 | 38 +++++++++++++ tests/xfs/1865.out | 2 + tests/xfs/1866 | 122 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1866.out | 19 ++++++ tests/xfs/1867 | 133 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1867.out | 25 ++++++++ tests/xfs/1868 | 121 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1868.out | 21 +++++++ tests/xfs/1869 | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1869.out | 32 +++++++++++ tests/xfs/1870 | 146 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1870.out | 30 ++++++++++ tests/xfs/1871 | 78 ++++++++++++++++++++++++++ tests/xfs/1871.out | 2 + 16 files changed, 966 insertions(+) create mode 100755 tests/xfs/1864 create mode 100644 tests/xfs/1864.out create mode 100755 tests/xfs/1865 create mode 100644 tests/xfs/1865.out create mode 100755 tests/xfs/1866 create mode 100644 tests/xfs/1866.out create mode 100755 tests/xfs/1867 create mode 100644 tests/xfs/1867.out create mode 100755 tests/xfs/1868 create mode 100644 tests/xfs/1868.out create mode 100755 tests/xfs/1869 create mode 100644 tests/xfs/1869.out create mode 100755 tests/xfs/1870 create mode 100644 tests/xfs/1870.out create mode 100755 tests/xfs/1871 create mode 100644 tests/xfs/1871.out
PATCH 1/2 common/fuzzy: stress directory tree modifications with the dirtree tester
From: Darrick J. Wong <[email protected]>
Stress test the directory tree corruption detector by racing it with fsstress.
--- tests/xfs/1864 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1864.out | 2 ++ tests/xfs/1865 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1865.out | 2 ++ 4 files changed, 80 insertions(+) create mode 100755 tests/xfs/1864 create mode 100644 tests/xfs/1864.out create mode 100755 tests/xfs/1865 create mode 100644 tests/xfs/1865.out
tests/xfs/1864 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1864 +# +# Race fsstress and directory tree structure corruption detector for a while to +# see if we crash or livelock. +# +. ./common/preamble +_begin_fstest scrub dangerous_fsstress_scrub + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +# real QA test starts here +_supported_fs xfs +_require_scratch +_require_xfs_stress_scrub + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_scratch_xfs_stress_scrub -x 'dir' -s "scrub dirtree" -t "%dir%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/1864.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1864 +Silence is golden
tests/xfs/1865 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1865 +# +# Race fsstress and directory tree structure repair for a while to see if we +# crash or livelock. +# +. ./common/preamble +_begin_fstest online_repair dangerous_fsstress_repair + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +# real QA test starts here +_supported_fs xfs +_require_scratch +_require_xfs_stress_online_repair + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_scratch_xfs_stress_online_repair -x 'dir' -s "repair dirtree" -t "%dir%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/1865.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1865 +Silence is golden
PATCH 2/2 scrub: test correction of directory tree corruptions
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Make sure that we can fix directory tree loops and multiply-owned dirs.
--- tests/xfs/1866 | 122 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1866.out | 19 ++++++ tests/xfs/1867 | 133 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1867.out | 25 ++++++++ tests/xfs/1868 | 121 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1868.out | 21 +++++++ tests/xfs/1869 | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1869.out | 32 +++++++++++ tests/xfs/1870 | 146 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1870.out | 30 ++++++++++ tests/xfs/1871 | 78 ++++++++++++++++++++++++++ tests/xfs/1871.out | 2 + 12 files changed, 886 insertions(+) create mode 100755 tests/xfs/1866 create mode 100644 tests/xfs/1866.out create mode 100755 tests/xfs/1867 create mode 100644 tests/xfs/1867.out create mode 100755 tests/xfs/1868 create mode 100644 tests/xfs/1868.out create mode 100755 tests/xfs/1869 create mode 100644 tests/xfs/1869.out create mode 100755 tests/xfs/1870 create mode 100644 tests/xfs/1870.out create mode 100755 tests/xfs/1871 create mode 100644 tests/xfs/1871.out
tests/xfs/1866 new file +122 -0
@@ -0,0 +1,122 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1866 +# +# Functional testing for online fsck of a directory loop that is not accessible +# from the root directory. +# +. ./common/preamble +_begin_fstest auto online_repair + +# Import common functions. +. ./common/filter +. ./common/inject +. ./common/fuzzy +. ./common/populate + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_require_xfs_db_command "link" +_require_xfs_db_command "unlink" +_require_scratch +_require_xfs_stress_online_repair + +prepare_fs() { + _scratch_mkfs >> $seqres.full + _scratch_mount + __stress_scrub_check_commands "%dir%" '' '' 'scrub dirtree' + + # Begin by creating the following directory tree: + # root["A"]->A + # A["B"]->B + # B["C"]->C + mkdir -p "$SCRATCH_MNT/A/B/C" + + root_inum="$(stat -c '%i' "$SCRATCH_MNT/")" + a_inum="$(stat -c '%i' "$SCRATCH_MNT/A")" + b_inum="$(stat -c '%i' "$SCRATCH_MNT/A/B")" + c_inum="$(stat -c '%i' "$SCRATCH_MNT/A/B/C")" + + echo "root: $root_inum; a: $a_inum; b: $b_inum; c: $c_inum" >> $seqres.full + + # Next, we complete the loop by creating C["A"]->A and deleting root["A"]->A. + # Directory tree is now: + # A["B"]->B + # B["C"]->C + # C["A"]->A + _scratch_unmount + + root_gen=$(_scratch_xfs_get_metadata_field core.gen "inode $root_inum") + a_gen=$(_scratch_xfs_get_metadata_field core.gen "inode $a_inum") + b_gen=$(_scratch_xfs_get_metadata_field core.gen "inode $b_inum") + c_gen=$(_scratch_xfs_get_metadata_field core.gen "inode $c_inum") + + _scratch_xfs_db \ + -c "echo before root $root_inum" -c "inode $root_inum" -c 'print core.nlinkv2' -c "ls" \ + -c "echo before C $c_inum" -c "inode $c_inum" -c 'print core.nlinkv2' -c "ls" \ + -c "echo before A $a_inum" -c "inode $a_inum" -c 'print core.nlinkv2' -c "parent" \ + >> $seqres.full + + _scratch_xfs_db -x \ + -c "inode $c_inum" -c "link -i $a_inum A" \ + -c "inode $root_inum" -c "unlink A" \ + >> $seqres.full + + _scratch_xfs_db \ + -c "echo after root $root_inum" -c "inode $root_inum" -c 'print core.nlinkv2' -c "ls" \ + -c "echo after C $c_inum" -c "inode $c_inum" -c 'print core.nlinkv2' -c "ls" \ + -c "echo after A $a_inum" -c "inode $a_inum" -c 'print core.nlinkv2' -c "parent" \ + >> $seqres.full +} + +simple_online_repair() { + echo "check root" + $XFS_IO_PROG -c "scrub dirtree $root_inum $root_gen" $SCRATCH_MNT + echo "check A" + $XFS_IO_PROG -c "scrub dirtree $a_inum $a_gen" $SCRATCH_MNT + echo "check B" + $XFS_IO_PROG -c "scrub dirtree $b_inum $b_gen" $SCRATCH_MNT + echo "check C" + $XFS_IO_PROG -c "scrub dirtree $c_inum $c_gen" $SCRATCH_MNT + + echo "repair root" + $XFS_IO_PROG -x -c "repair dirtree $root_inum $root_gen" $SCRATCH_MNT + echo "repair A" + $XFS_IO_PROG -x -c "repair dirtree $a_inum $a_gen" $SCRATCH_MNT + echo "repair B" + $XFS_IO_PROG -x -c "repair dirtree $b_inum $b_gen" $SCRATCH_MNT + echo "repair C" + $XFS_IO_PROG -x -c "repair dirtree $c_inum $c_gen" $SCRATCH_MNT + + echo "check root" + $XFS_IO_PROG -c "scrub dirtree $root_inum $root_gen" $SCRATCH_MNT + echo "check A" + $XFS_IO_PROG -c "scrub dirtree $a_inum $a_gen" $SCRATCH_MNT + echo "check B" + $XFS_IO_PROG -c "scrub dirtree $b_inum $b_gen" $SCRATCH_MNT + echo "check C" + $XFS_IO_PROG -c "scrub dirtree $c_inum $c_gen" $SCRATCH_MNT +} + +# Part 1: Use raw ioctls to detect the loop and fix it. +prepare_fs +_scratch_mount +simple_online_repair +_check_scratch_fs +_scratch_unmount + +# Part 2: Use xfs_scrub to detect the loop and fix it. +prepare_fs +_scratch_mount +_scratch_scrub &>> $seqres.full +echo "xfs_scrub returned $?" >> $seqres.full +_check_scratch_fs +_scratch_unmount + +# success, all done +status=0 +exit
tests/xfs/1866.out new file +19 -0
@@ -0,0 +1,19 @@ +QA output created by 1866 +check root +check A +Corruption detected. +check B +Corruption detected. +check C +Corruption detected. +repair root +Metadata did not need repair or optimization. +repair A +repair B +Metadata did not need repair or optimization. +repair C +Metadata did not need repair or optimization. +check root +check A +check B +check C
tests/xfs/1867 new file +133 -0
133 lines not on this page · raw message
tests/xfs/1867.out new file +25 -0
@@ -0,0 +1,25 @@ +QA output created by 1867 +check root +check A +check B +Corruption detected. +check C +Corruption detected during cross-referencing. +check D +Corruption detected during cross-referencing. +repair root +Metadata did not need repair or optimization. +repair A +Metadata did not need repair or optimization. +repair D +Corruption still detected during cross-referencing. +repair B +repair C +Metadata did not need repair or optimization. +repair D +Metadata did not need repair or optimization. +check root +check A +check B +check C +check D
tests/xfs/1868 new file +121 -0
121 lines not on this page · raw message
tests/xfs/1868.out new file +21 -0
@@ -0,0 +1,21 @@ +QA output created by 1868 +check root +check A +Corruption detected. +check B +Corruption detected during cross-referencing. +check C +Corruption detected during cross-referencing. +repair C +Corruption still detected during cross-referencing. +repair root +Metadata did not need repair or optimization. +repair A +repair B +Metadata did not need repair or optimization. +repair C +Metadata did not need repair or optimization. +check root +check A +check B +check C
tests/xfs/1869 new file +157 -0
157 lines not on this page · raw message
tests/xfs/1869.out new file +32 -0
@@ -0,0 +1,32 @@ +QA output created by 1869 +check root +check A +check B +check C +Corruption detected. +check D +Corruption detected during cross-referencing. +check Z +check Y +repair D +Corruption still detected during cross-referencing. +repair root +Metadata did not need repair or optimization. +repair A +Metadata did not need repair or optimization. +repair B +Metadata did not need repair or optimization. +repair C +repair D +Metadata did not need repair or optimization. +repair Z +Metadata did not need repair or optimization. +repair Y +Metadata did not need repair or optimization. +check root +check A +check B +check C +check D +check Z +check Y
tests/xfs/1870 new file +146 -0
146 lines not on this page · raw message
tests/xfs/1870.out new file +30 -0
@@ -0,0 +1,30 @@ +QA output created by 1870 +check root +check A +check B +Corruption detected. +check C +Corruption detected. +check D +Corruption detected. +check E +Corruption detected during cross-referencing. +repair root +Metadata did not need repair or optimization. +repair A +Metadata did not need repair or optimization. +repair E +Corruption still detected during cross-referencing. +repair B +repair C +Metadata did not need repair or optimization. +repair D +Metadata did not need repair or optimization. +repair E +Metadata did not need repair or optimization. +check root +check A +check B +check C +check D +check E
tests/xfs/1871 new file +78 -0
78 lines not on this page · raw message
tests/xfs/1871.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1871 +Silence is golden
PATCH 5/6 xfs_scrub: vectorize kernel calls
In reply to Darrick J. WongHi all,
Create a vectorized version of the metadata scrub and repair ioctl, and adapt xfs_scrub to use that. This is an experiment to measure overhead and to try refactoring xfs_scrub.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=vectorized-scrub
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=vectorized-scrub
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=vectorized-scrub
---
Commits in this patchset:
* xfs/122: update for vectored scrub
--- tests/xfs/122.out | 2 ++ 1 file changed, 2 insertions(+)
PATCH 1/1 xfs/122: update for vectored scrub
From: Darrick J. Wong <[email protected]>
Add the two new vectored scrub structures.
--- tests/xfs/122.out | 2 ++ 1 file changed, 2 insertions(+)
tests/xfs/122.out +2 -0
@@ -124,6 +124,8 @@ sizeof(struct xfs_rtrmap_root) = 4 sizeof(struct xfs_rud_log_format) = 16 sizeof(struct xfs_rui_log_format) = 16 sizeof(struct xfs_scrub_metadata) = 64 +sizeof(struct xfs_scrub_vec) = 16 +sizeof(struct xfs_scrub_vec_head) = 40 sizeof(struct xfs_swap_extent) = 64 sizeof(struct xfs_unmount_log_format) = 8 sizeof(struct xfs_xmd_log_format) = 16
PATCH 6/6 fstests: minor fixes for 6.10-rc1
In reply to Darrick J. WongHi all,
Here are some fixes for the stuff that just got merged for 6.10-rc1.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=xfs-6.10-fixes
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=xfs-6.10-fixes
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=xfs-6.10-fixes
---
Commits in this patchset:
* xfs/348: partially revert dbcc549317 ("xfs/348: golden output is not correct")
* generic: test creating and removing symlink xattrs
--- tests/generic/1836 | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1836.out | 2 ++ tests/xfs/348.out | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 tests/generic/1836 create mode 100644 tests/generic/1836.out
PATCH 1/2 xfs/348: partially revert dbcc549317 ("xfs/348: golden output is not correct")
From: Dave Chinner <[email protected]>
In kernel commit 1eb70f54c445f ("xfs: validate inode fork size against fork format"), we incorrectly started flagging as corrupt symlinks with short targets that would fit in the inode core but are remote. The kernel has historically written out symlinks this way and read them back in, so we're fixing that.
The 1eb70 change came with change dbcc to fstests to adjust the golden output; since we're adjusting the kernel back to old behavior, we need to adjust the test too.
--- tests/xfs/348.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/348.out +1 -1
@@ -240,7 +240,7 @@ would have junked entry "DIR" in directory PARENT_INO would have junked entry "EMPTY" in directory PARENT_INO would have junked entry "FIFO" in directory PARENT_INO stat: cannot statx 'SCRATCH_MNT/test/DIR': Structure needs cleaning -stat: cannot statx 'SCRATCH_MNT/test/DATA': Structure needs cleaning +stat: 'SCRATCH_MNT/test/DATA' is a symbolic link stat: cannot statx 'SCRATCH_MNT/test/EMPTY': Structure needs cleaning stat: 'SCRATCH_MNT/test/SYMLINK' is a symbolic link stat: cannot statx 'SCRATCH_MNT/test/CHRDEV': Structure needs cleaning
PATCH 2/2 generic: test creating and removing symlink xattrs
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
This began as a regression test for the issues identified in "xfs: allow symlinks with short remote targets". To summarize, the kernel XFS code does not convert a remote symlink back to a shortform symlink after deleting the attr fork. Recent attempts to tighten validation have flagged this incorrectly, so we need a regression test to focus on this dusty corner of the codebase.
However, there's nothing in here that's xfs-specific so it's a generic test.
--- tests/generic/1836 | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1836.out | 2 ++ 2 files changed, 60 insertions(+) create mode 100755 tests/generic/1836 create mode 100644 tests/generic/1836.out
tests/generic/1836 new file +58 -0
@@ -0,0 +1,58 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test 1836 +# +# Test that we can add xattrs to a symbolic link, remove all the xattrs, and +# that the symbolic link doesn't get corrupted. This is a regression test for +# some incorrect checks in the xfs inode verifier. +# +. ./common/preamble +_begin_fstest auto + +_supported_fs generic +_require_scratch + +test $FSTYP = "xfs" && \ + _fixed_by_git_commit kernel XXXXXXXXXXXXX \ + "xfs: allow symlinks with short remote targets" + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +SYMLINK_ADD="0123456789ABCDEF01234567890ABCDEF" + +# test from 32 to MAXPATHLEN sized symlink. This should make sure that +# 256-1024 byte version 2 and 3 inodes are covered. +SYMLINK="" +for ((SIZE = 32; SIZE < 1024; SIZE += 32)); do + SYMLINK_FILE="$SCRATCH_MNT/symlink.$SIZE" + SYMLINK="${SYMLINK}${SYMLINK_ADD}" + ln -s $SYMLINK $SYMLINK_FILE > /dev/null 2>&1 + +# add the extended attributes + attr -Rs 1234567890ab $SYMLINK_FILE < /dev/null > /dev/null 2>&1 + attr -Rs 1234567890ac $SYMLINK_FILE < /dev/null > /dev/null 2>&1 + attr -Rs 1234567890ad $SYMLINK_FILE < /dev/null > /dev/null 2>&1 +# remove the extended attributes + attr -Rr 1234567890ab $SYMLINK_FILE > /dev/null 2>&1 + attr -Rr 1234567890ac $SYMLINK_FILE > /dev/null 2>&1 + attr -Rr 1234567890ad $SYMLINK_FILE > /dev/null 2>&1 +done + +_scratch_cycle_mount + +# Now check the symlink target contents +SYMLINK="" +for ((SIZE = 32; SIZE < 1024; SIZE += 32)); do + SYMLINK_FILE="$SCRATCH_MNT/symlink.$SIZE" + SYMLINK="${SYMLINK}${SYMLINK_ADD}" + + target="$(readlink $SYMLINK_FILE)" + test "$target" = "$SYMLINK" || echo "$SYMLINK_FILE: target is corrupt" +done + +echo Silence is golden +status=0 +exit
tests/generic/1836.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1836 +Silence is golden
Quoted 10 lines · Darrick J. Wong
Hi everyone,
This patchbomb are all the fixes that xfs needs to bring fstests up to date with what's in 6.10-rc. Except for these two patches:
[PATCHSET v30.7 2/6] fstests: atomic file updates [PATCH 03/11] generic/709,710: rework these for exchangerange vs. [PATCH 04/11] generic/711,xfs/537: actually fork these tests for
everything else in here is fully reviewed and ready for PRs.
Thanks for big updates!
This patchset is big, I've merged and pushed all these patches to fstests' 'patches-in-queue' branch, feel free to check that.
I need more time to give them more tests, will try to release fstests at this weekend or middle of next week.
Thanks,
Zorro
Quoted 3 lines
--D
Quoted 12 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong
Hi everyone,
This patchbomb are all the fixes that xfs needs to bring fstests up to date with what's in 6.10-rc. Except for these two patches:
[PATCHSET v30.7 2/6] fstests: atomic file updates [PATCH 03/11] generic/709,710: rework these for exchangerange vs. [PATCH 04/11] generic/711,xfs/537: actually fork these tests for
everything else in here is fully reviewed and ready for PRs.
Quoted 7 lines
Thanks for big updates!
This patchset is big, I've merged and pushed all these patches to fstests' 'patches-in-queue' branch, feel free to check that.
I need more time to give them more tests, will try to release fstests at this weekend or middle of next week.
<nod> The patch "src/fiexchange.h: update XFS_IOC_EXCHANGE_RANGE definitions" is going to need another update if Chandan pulls in[1] before 6.10 closes:
[1] https://lore.kernel.org/linux-xfs/171892459317.3192151.14305994848485102437.stgit@frogsfrogsfrogs/
But I'll let that go upstream before I make the change to fstests.
--D
Quoted 8 lines
Thanks,
ZorroQuoted 3 lines
--D