fstests: copy_file_range() tests
v2 cover fstests: copy_file_range() tests
Eryu,
This is a re-work of Dave Chinner's copy_file_range() tests which I used to verify the kernel fixes of the syscall [1].
I split out the single bounds test by Dave to 4 tests. immutable and swap file copy have specific requiremenet which many filesystems do not meet (e.g. cifs,nfs,ceph,overlayfs), so those test cases were split to individual test to allow better bounds test converage for all filesystems.
The 3 first tests fix bugs in the interface, so they are appropriate for merge IMO. The last test (cross-device copy) tests a new functionality, so you may want to wait with merge till after the work is merged upstream.
NOTE that the bounds check test depend on changes that have been merged to xfsprogs v4.20. Without those changes the test will hang! I used an artificial requirement _require_xfs_io_command "chmod" to skip the test with old xfs_io. I welcome suggestions for better way to handle this issue.
Thanks,
Amir.
Changes from v1:
- Remove patch to test EINVAL behavior instead of short copy
- Remove 'chmod -r' permission drop test case
- Split out test for swap/immutable file copy
- Split of cross-device copy test
[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
Amir Goldstein (5):
generic: create copy_range group
generic: copy_file_range immutable file test
generic: copy_file_range swapfile test
generic: copy_file_range bounds test
generic: cross-device copy_file_range test
tests/generic/434 | 2 + tests/generic/988 | 59 ++++++++++++++++++++ tests/generic/988.out | 5 ++ tests/generic/989 | 56 +++++++++++++++++++ tests/generic/989.out | 4 ++ tests/generic/990 | 123 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/990.out | 37 +++++++++++++ tests/generic/991 | 56 +++++++++++++++++++ tests/generic/991.out | 4 ++ tests/generic/group | 14 +++-- 10 files changed, 355 insertions(+), 5 deletions(-) create mode 100755 tests/generic/988 create mode 100644 tests/generic/988.out create mode 100755 tests/generic/989 create mode 100644 tests/generic/989.out create mode 100755 tests/generic/990 create mode 100644 tests/generic/990.out create mode 100755 tests/generic/991 create mode 100644 tests/generic/991.out
Signature · 1 line
2.17.1
PATCH v2 1/5 generic: create copy_range group
Move some tests to the copy_range group so they are distinct from the copy group which refers to xfs_copy tests.
[Amir] Revert copy past EOF behavior change
--- tests/generic/434 | 2 ++ tests/generic/group | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-)
tests/generic/434 +2 -0
@@ -46,10 +46,12 @@ $XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy" md5sum $testdir/copy | _filter_test_dir echo "Try to copy to a read-only file" +rm -f $testdir/copy $XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy" md5sum $testdir/copy | _filter_test_dir echo "Try to copy to an append-only file" +rm -f $testdir/copy $XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy" md5sum $testdir/copy | _filter_test_dir
tests/generic/group +5 -5
@@ -432,11 +432,11 @@ 427 auto quick aio rw 428 auto quick dax 429 auto encrypt -430 auto quick copy -431 auto quick copy -432 auto quick copy -433 auto quick copy -434 auto quick copy +430 auto quick copy_range +431 auto quick copy_range +432 auto quick copy_range +433 auto quick copy_range +434 auto quick copy_range 435 auto encrypt 436 auto quick rw seek prealloc 437 auto quick dax
Signature · 1 line
2.17.1
PATCH v2 2/5 generic: copy_file_range immutable file test
In reply to Amir GoldsteinThis test case was split out of Dave Chinner's copy_file_range bounds check test to reduce the requirements for running the bounds check.
--- tests/generic/988 | 59 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/988.out | 5 ++++ tests/generic/group | 1 + 3 files changed, 65 insertions(+) create mode 100755 tests/generic/988 create mode 100644 tests/generic/988.out
tests/generic/988 new file +59 -0
@@ -0,0 +1,59 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 988 +# +# Check that we cannot copy_file_range() to/from an immutable file +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 7 15 + +_cleanup() +{ + $CHATTR_PROG -i $testdir/immutable > /dev/null 2>&1 + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full + +_require_test +_require_chattr i +_require_xfs_io_command "copy_range" +_require_xfs_io_command "chattr" + +testdir="$TEST_DIR/test-$seq" +rm -rf $testdir +mkdir $testdir + +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +# we have to open the file to be immutable rw and hold it open over the +# chattr command to set it immutable, otherwise we won't be able to open it for +# writing after it's been made immutable. (i.e. would exercise file mode checks, +# not immutable inode flag checks). +echo immutable file returns EPERM +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 64k" -c fsync $testdir/immutable | _filter_xfs_io +$XFS_IO_PROG -f -c "chattr +i" -c "copy_range -l 32k $testdir/file" $testdir/immutable +$XFS_IO_PROG -f -r -c "chattr -i" $testdir/immutable + +# success, all done +status=0 +exit
tests/generic/988.out new file +5 -0
@@ -0,0 +1,5 @@ +QA output created by 988 +immutable file returns EPERM +wrote 65536/65536 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +copy_range: Operation not permitted
tests/generic/group +1 -0
@@ -550,3 +550,4 @@ 545 auto quick cap 546 auto quick clone enospc log 547 auto quick log +988 auto quick copy_range
Signature · 1 line
2.17.1
PATCH v2 3/5 generic: copy_file_range swapfile test
In reply to Amir GoldsteinThis test case was split out of Dave Chinner's copy_file_range bounds check test to reduce the requirements for running the bounds check.
--- tests/generic/989 | 56 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/989.out | 4 ++++ tests/generic/group | 1 + 3 files changed, 61 insertions(+) create mode 100755 tests/generic/989 create mode 100644 tests/generic/989.out
tests/generic/989 new file +56 -0
@@ -0,0 +1,56 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 989 +# +# Check that we cannot copy_file_range() to/from a swapfile +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full + +_require_scratch +_require_xfs_io_command "copy_range" +_require_scratch_swapfile + +_scratch_mkfs 2>&1 >> $seqres.full +_scratch_mount + +testdir=$SCRATCH_MNT + +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +echo swap files return ETXTBUSY +_format_swapfile $testdir/swapfile 16m +swapon $testdir/swapfile +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/file" $testdir/swapfile +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/swapfile" $testdir/copy +swapoff $testdir/swapfile + +# success, all done +status=0 +exit
tests/generic/989.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 989 +swap files return ETXTBUSY +copy_range: Text file busy +copy_range: Text file busy
tests/generic/group +1 -0
@@ -551,3 +551,4 @@ 546 auto quick clone enospc log 547 auto quick log 988 auto quick copy_range +989 auto quick copy_range swap
Signature · 1 line
2.17.1
PATCH v2 4/5 generic: copy_file_range bounds test
In reply to Amir GoldsteinTest that copy_file_range will return the correct errors for various error conditions and boundary constraints.
[Amir] Split out cross-device copy_range test and use only scratch dev. Split out immutable/swapfile test cases to reduce the requirements to run the bounds check to minimum and get coverage for more filesystems. Remove the tests for read past EOF and write after chmod -r, because we decided to stick with read(2)/write(2) semantics.
--- tests/generic/990 | 123 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/990.out | 37 +++++++++++++ tests/generic/group | 1 + 3 files changed, 161 insertions(+) create mode 100755 tests/generic/990 create mode 100644 tests/generic/990.out
tests/generic/990 new file +123 -0
@@ -0,0 +1,123 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 990 +# +# Exercise copy_file_range() syscall error conditions. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full + +_require_test +_require_xfs_io_command "copy_range" +# +# This test effectively requires xfs_io v4.20 with the commits +# 2a42470b xfs_io: copy_file_range length is a size_t +# 1a05efba io: open pipes in non-blocking mode +# +# The same xfs_io release also included the new 'chmod' command. +# Use this fake requirement to prevent the test case of copy_range with fifo +# from hanging the test with old xfs_io. +# +_require_xfs_io_command "chmod" + +testdir="$TEST_DIR/test-$seq" +rm -rf $testdir +mkdir $testdir + +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +echo source range overlaps destination range in same file returns EINVAL +$XFS_IO_PROG -f -c "copy_range -s 32k -d 48k -l 32k $testdir/file" $testdir/file + +echo +echo destination file O_RDONLY returns EBADF +$XFS_IO_PROG -f -r -c "copy_range -l 32k $testdir/file" $testdir/copy + +echo +echo destination file O_APPEND returns EBADF +$XFS_IO_PROG -f -a -c "copy_range -l 32k $testdir/file" $testdir/copy + +echo +echo source/destination as directory returns EISDIR +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir" $testdir/copy + +echo +echo source/destination as blkdev returns EINVAL +mknod $testdir/dev1 b 1 3 +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/dev1 +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/dev1" $testdir/copy + +echo +echo source/destination as chardev returns EINVAL +mknod $testdir/dev2 c 1 3 +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/dev2 +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/dev2" $testdir/copy + +echo +echo source/destination as FIFO returns EINVAL +mkfifo $testdir/fifo +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/fifo +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/fifo" $testdir/copy + +max_off=$((8 * 2**60 - 65536 - 1)) +min_off=65537 + +echo +echo length beyond 8EiB wraps around 0 returns EOVERFLOW +$XFS_IO_PROG -f -c "copy_range -l 10e -s $max_off $testdir/file" $testdir/copy +$XFS_IO_PROG -f -c "copy_range -l 10e -d $max_off $testdir/file" $testdir/copy + +echo +echo source range beyond 8TiB returns 0 +$XFS_IO_PROG -c "copy_range -s $max_off -l $min_off -d 0 $testdir/file" $testdir/copy + +echo +echo destination range beyond 8TiB returns EFBIG +$XFS_IO_PROG -c "copy_range -l $min_off -s 0 -d $max_off $testdir/file" $testdir/copy + +echo +echo destination larger than rlimit returns EFBIG +rm -f $testdir/copy +$XFS_IO_PROG -c "truncate 128k" $testdir/file + +# need a wrapper so the "File size limit exceeded" error can be filtered +do_rlimit_copy() +{ + $XFS_IO_PROG -f -c "copy_range -l 32k -s 0 -d 16m $testdir/file" $testdir/copy +} + +ulimit -f $((8 * 1024)) +ulimit -c 0 +do_rlimit_copy 2>&1 | grep -o "File size limit exceeded" +ulimit -f unlimited + +# success, all done +status=0 +exit
tests/generic/990.out new file +37 -0
@@ -0,0 +1,37 @@ +QA output created by 990 +source range overlaps destination range in same file returns EINVAL +copy_range: Invalid argument + +destination file O_RDONLY returns EBADF +copy_range: Bad file descriptor + +destination file O_APPEND returns EBADF +copy_range: Bad file descriptor + +source/destination as directory returns EISDIR +copy_range: Is a directory +copy_range: Is a directory + +source/destination as blkdev returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +source/destination as chardev returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +source/destination as FIFO returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +length beyond 8EiB wraps around 0 returns EOVERFLOW +copy_range: Value too large for defined data type +copy_range: Value too large for defined data type + +source range beyond 8TiB returns 0 + +destination range beyond 8TiB returns EFBIG +copy_range: File too large + +destination larger than rlimit returns EFBIG +File size limit exceeded
tests/generic/group +1 -0
@@ -552,3 +552,4 @@ 547 auto quick log 988 auto quick copy_range 989 auto quick copy_range swap +990 auto quick copy_range
Signature · 1 line
2.17.1
Re: [PATCH v2 4/5] generic: copy_file_range bounds test
Quoted 54 lines · Amir Goldstein
Test that
copy_file_rangewill return the correct errors for various error conditions and boundary constraints.[Amir] Split out cross-device
copy_rangetest and use only scratch dev. Split out immutable/swapfile test cases to reduce the requirements to run the bounds check to minimum and get coverage for more filesystems. Remove the tests for read past EOF and write after chmod -r, because we decided to stick with read(2)/write(2) semantics.Signed-off-by Dave Chinner <[email protected]>Signed-off-by Amir Goldstein <[email protected]>--- tests/generic/990 | 123 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/990.out | 37 +++++++++++++ tests/generic/group | 1 + 3 files changed, 161 insertions(+) create mode 100755 tests/generic/990 create mode 100644 tests/generic/990.outtests/generic/990 new file +29
-0@@ -0,0 +1,123 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 990 +# +# Exercise copy_file_range() syscall error conditions. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux
tests/generic/990 line 39
Quoted 10 lines
tests/generic/990 new file +10
-0+_supported_fs generic + +rm -f $seqres.full + +_require_test +_require_xfs_io_command "copy_range" +# +# This test effectively requires xfs_io v4.20 with the commits +# 2a42470b xfs_io: copy_file_range length is a size_t +# 1a05efba io: open pipes in non-blocking mode
So, uh, is this going to cause test hangs on xfsprogs < 4.20?
--D
Quoted 139 lines
tests/generic/990 new file +84
-0+# +# The same xfs_io release also included the new 'chmod' command. +# Use this fake requirement to prevent the test case of copy_range with fifo +# from hanging the test with old xfs_io. +# +_require_xfs_io_command "chmod" + +testdir="$TEST_DIR/test-$seq" +rm -rf $testdir +mkdir $testdir + +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +echo source range overlaps destination range in same file returns EINVAL +$XFS_IO_PROG -f -c "copy_range -s 32k -d 48k -l 32k $testdir/file" $testdir/file + +echo +echo destination file O_RDONLY returns EBADF +$XFS_IO_PROG -f -r -c "copy_range -l 32k $testdir/file" $testdir/copy + +echo +echo destination file O_APPEND returns EBADF +$XFS_IO_PROG -f -a -c "copy_range -l 32k $testdir/file" $testdir/copy + +echo +echo source/destination as directory returns EISDIR +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir" $testdir/copy + +echo +echo source/destination as blkdev returns EINVAL +mknod $testdir/dev1 b 1 3 +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/dev1 +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/dev1" $testdir/copy + +echo +echo source/destination as chardev returns EINVAL +mknod $testdir/dev2 c 1 3 +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/dev2 +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/dev2" $testdir/copy + +echo +echo source/destination as FIFO returns EINVAL +mkfifo $testdir/fifo +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/fifo +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/fifo" $testdir/copy + +max_off=$((8 * 2**60 - 65536 - 1)) +min_off=65537 + +echo +echo length beyond 8EiB wraps around 0 returns EOVERFLOW +$XFS_IO_PROG -f -c "copy_range -l 10e -s $max_off $testdir/file" $testdir/copy +$XFS_IO_PROG -f -c "copy_range -l 10e -d $max_off $testdir/file" $testdir/copy + +echo +echo source range beyond 8TiB returns 0 +$XFS_IO_PROG -c "copy_range -s $max_off -l $min_off -d 0 $testdir/file" $testdir/copy + +echo +echo destination range beyond 8TiB returns EFBIG +$XFS_IO_PROG -c "copy_range -l $min_off -s 0 -d $max_off $testdir/file" $testdir/copy + +echo +echo destination larger than rlimit returns EFBIG +rm -f $testdir/copy +$XFS_IO_PROG -c "truncate 128k" $testdir/file + +# need a wrapper so the "File size limit exceeded" error can be filtered +do_rlimit_copy() +{ + $XFS_IO_PROG -f -c "copy_range -l 32k -s 0 -d 16m $testdir/file" $testdir/copy +} + +ulimit -f $((8 * 1024)) +ulimit -c 0 +do_rlimit_copy 2>&1 | grep -o "File size limit exceeded" +ulimit -f unlimited + +# success, all done +status=0 +exittests/generic/990.out new file +37
-0@@ -0,0 +1,37 @@ +QA output created by 990 +source range overlaps destination range in same file returns EINVAL +copy_range: Invalid argument + +destination file O_RDONLY returns EBADF +copy_range: Bad file descriptor + +destination file O_APPEND returns EBADF +copy_range: Bad file descriptor + +source/destination as directory returns EISDIR +copy_range: Is a directory +copy_range: Is a directory + +source/destination as blkdev returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +source/destination as chardev returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +source/destination as FIFO returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +length beyond 8EiB wraps around 0 returns EOVERFLOW +copy_range: Value too large for defined data type +copy_range: Value too large for defined data type + +source range beyond 8TiB returns 0 + +destination range beyond 8TiB returns EFBIG +copy_range: File too large + +destination larger than rlimit returns EFBIG +File size limit exceededtests/generic/group +1
-0@@ -552,3 +552,4 @@ 547 auto quick log 988 auto quick copy_range 989 auto quick copy_range swap +990 auto quick copy_rangeSignature · 1 line
2.17.1
Re: [PATCH v2 4/5] generic: copy_file_range bounds test
Quoted 60 lines · Darrick J. Wong
Quoted 58 lines · Amir Goldstein
Test that
copy_file_rangewill return the correct errors for various error conditions and boundary constraints.[Amir] Split out cross-device
copy_rangetest and use only scratch dev. Split out immutable/swapfile test cases to reduce the requirements to run the bounds check to minimum and get coverage for more filesystems. Remove the tests for read past EOF and write after chmod -r, because we decided to stick with read(2)/write(2) semantics.Signed-off-by Dave Chinner <[email protected]>Signed-off-by Amir Goldstein <[email protected]>--- tests/generic/990 | 123 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/990.out | 37 +++++++++++++ tests/generic/group | 1 + 3 files changed, 161 insertions(+) create mode 100755 tests/generic/990 create mode 100644 tests/generic/990.outtests/generic/990 new file +33
-0@@ -0,0 +1,123 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 990 +# +# Exercise copy_file_range() syscall error conditions. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full +
Quoted 8 lines
tests/generic/990 line 39
Quoted 6 lines
tests/generic/990 new file +6
-0+_require_test +_require_xfs_io_command "copy_range" +# +# This test effectively requires xfs_io v4.20 with the commits +# 2a42470b xfs_io: copy_file_range length is a size_t +# 1a05efba io: open pipes in non-blocking modeSo, uh, is this going to cause test hangs on xfsprogs < 4.20?
Yes, from the pipe test case:
$XFS_IO_PROG -f -c "copy_range -l 32k $testdir/fifo" $testdir/copy
I could introduce _require_xfs_io_min_ver, but it goes completely against "testing features" methodology.
I guess I could implement _require_xfs_io_non_block_fifo, but that also seems quite ugly to me?
BTW, per your comment about splitting the fifo test case, I believe that would be wrong.
I split the swap/immutable file test cases to provide better bounds test coverage for filesystems that do not support swap/immutable files.
If I split the fifo test case, it will provide better bounds test coverage for test setups with old xfs_io and new kernel (in old kernel bounds test will fail anyway), so what do users gain from that?
Thanks,
Amir.
PATCH v2 5/5 generic: cross-device copy_file_range test
In reply to Amir GoldsteinOld kernels do not support cross-device copy_file_range. A new patch set is aimed at allowing cross-device copy_file_range using the default in-kernel copy implementation.
[Amir] Split out cross-device copy_range test to a new test.
--- tests/generic/991 | 56 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/991.out | 4 ++++ tests/generic/group | 1 + 3 files changed, 61 insertions(+) create mode 100755 tests/generic/991 create mode 100644 tests/generic/991.out
tests/generic/991 new file +56 -0
@@ -0,0 +1,56 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 991 +# +# Exercise copy_file_range() across devices +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full + +_require_test +_require_scratch +_require_xfs_io_command "copy_range" + +_scratch_mkfs 2>&1 >> $seqres.full +_scratch_mount + + +testdir=$TEST_DIR/test-$seq +rm -rf $testdir +mkdir $testdir +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +$XFS_IO_PROG -f -c "copy_range -l 128k $testdir/file" $SCRATCH_MNT/copy +cmp $testdir/file $SCRATCH_MNT/copy +echo "md5sums after xdev copy:" +md5sum $testdir/file $SCRATCH_MNT/copy | _filter_test_dir | _filter_scratch + +# success, all done +status=0 +exit
tests/generic/991.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 991 +md5sums after xdev copy: +81615449a98aaaad8dc179b3bec87f38 TEST_DIR/test-991/file +81615449a98aaaad8dc179b3bec87f38 SCRATCH_MNT/copy
tests/generic/group +1 -0
@@ -553,3 +553,4 @@ 988 auto quick copy_range 989 auto quick copy_range swap 990 auto quick copy_range +991 auto quick copy_range
Signature · 1 line
2.17.1
Quoted 11 lines · Amir Goldstein
Eryu,
This is a re-work of Dave Chinner's
copy_file_range()tests which I used to verify the kernel fixes of the syscall [1].I split out the single bounds test by Dave to 4 tests. immutable and swap file copy have specific requiremenet which many filesystems do not meet (e.g. cifs,nfs,ceph,overlayfs), so those test cases were split to individual test to allow better bounds test converage for all filesystems.
Quoted 4 lines
The 3 first tests fix bugs in the interface, so they are appropriate for merge IMO. The last test (cross-device copy) tests a new functionality, so you may want to wait with merge till after the work is merged upstream.
The tests mostly look ok to me...
Quoted 2 lines
NOTE that the bounds check test depend on changes that have been merged to xfsprogs v4.20. Without those changes the test will hang!
Is that the requirement for opening pipes in nonblocking mode?
If so... that ought to be a separate test (or at least a separate part of the test) that can be skipped if we detect an old xfs_io.
Quoted 3 lines
I used an artificial requirement
_require_xfs_io_command"chmod" to skip the test with oldxfs_io. I welcome suggestions for better way to handle this issue.
Grepping manpages? :D
--D
Quoted 42 lines
Thanks,
Amir.Changes from v1:
- Remove patch to test EINVAL behavior instead of short copy
- Remove 'chmod -r' permission drop test case
- Split out test for swap/immutable file copy
- Split of cross-device copy test[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
Amir Goldstein (5):
generic: createcopy_rangegroup
generic:copy_file_rangeimmutable file test
generic:copy_file_rangeswapfile test
generic:copy_file_rangebounds test
generic: cross-devicecopy_file_rangetesttests/generic/434 | 2 + tests/generic/988 | 59 ++++++++++++++++++++ tests/generic/988.out | 5 ++ tests/generic/989 | 56 +++++++++++++++++++ tests/generic/989.out | 4 ++ tests/generic/990 | 123 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/990.out | 37 +++++++++++++ tests/generic/991 | 56 +++++++++++++++++++ tests/generic/991.out | 4 ++ tests/generic/group | 14 +++-- 10 files changed, 355 insertions(+), 5 deletions(-) create mode 100755 tests/generic/988 create mode 100644 tests/generic/988.out create mode 100755 tests/generic/989 create mode 100644 tests/generic/989.out create mode 100755 tests/generic/990 create mode 100644 tests/generic/990.out create mode 100755 tests/generic/991 create mode 100644 tests/generic/991.outSignature · 1 line
2.17.1