* [PATCH v2 1/5] generic: create copy_range group
2019-05-26 8:45 [PATCH v2 0/5] fstests: copy_file_range() tests Amir Goldstein
@ 2019-05-26 8:45 ` Amir Goldstein
2019-05-26 8:45 ` [PATCH v2 2/5] generic: copy_file_range immutable file test Amir Goldstein
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2019-05-26 8:45 UTC (permalink / raw)
To: Eryu Guan
Cc: Dave Chinner, Darrick J . Wong, fstests, linux-xfs, Dave Chinner
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
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/generic/434 | 2 ++
tests/generic/group | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/generic/434 b/tests/generic/434
index 032f933d..edbf49d3 100755
--- a/tests/generic/434
+++ b/tests/generic/434
@@ -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
diff --git a/tests/generic/group b/tests/generic/group
index 49639fc9..b498eb56 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -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
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 2/5] generic: copy_file_range immutable file test
2019-05-26 8:45 [PATCH v2 0/5] fstests: copy_file_range() tests Amir Goldstein
2019-05-26 8:45 ` [PATCH v2 1/5] generic: create copy_range group Amir Goldstein
@ 2019-05-26 8:45 ` Amir Goldstein
2019-05-26 8:45 ` [PATCH v2 3/5] generic: copy_file_range swapfile test Amir Goldstein
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2019-05-26 8:45 UTC (permalink / raw)
To: Eryu Guan; +Cc: Dave Chinner, Darrick J . Wong, fstests, linux-xfs
This test case was split out of Dave Chinner's copy_file_range bounds
check test to reduce the requirements for running the bounds check.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
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
diff --git a/tests/generic/988 b/tests/generic/988
new file mode 100755
index 00000000..0f4ee4ea
--- /dev/null
+++ b/tests/generic/988
@@ -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
diff --git a/tests/generic/988.out b/tests/generic/988.out
new file mode 100644
index 00000000..e74a96bf
--- /dev/null
+++ b/tests/generic/988.out
@@ -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
diff --git a/tests/generic/group b/tests/generic/group
index b498eb56..20b95c14 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -550,3 +550,4 @@
545 auto quick cap
546 auto quick clone enospc log
547 auto quick log
+988 auto quick copy_range
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 3/5] generic: copy_file_range swapfile test
2019-05-26 8:45 [PATCH v2 0/5] fstests: copy_file_range() tests Amir Goldstein
2019-05-26 8:45 ` [PATCH v2 1/5] generic: create copy_range group Amir Goldstein
2019-05-26 8:45 ` [PATCH v2 2/5] generic: copy_file_range immutable file test Amir Goldstein
@ 2019-05-26 8:45 ` Amir Goldstein
2019-05-26 8:45 ` [PATCH v2 4/5] generic: copy_file_range bounds test Amir Goldstein
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2019-05-26 8:45 UTC (permalink / raw)
To: Eryu Guan; +Cc: Dave Chinner, Darrick J . Wong, fstests, linux-xfs
This test case was split out of Dave Chinner's copy_file_range bounds
check test to reduce the requirements for running the bounds check.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
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
diff --git a/tests/generic/989 b/tests/generic/989
new file mode 100755
index 00000000..27c10296
--- /dev/null
+++ b/tests/generic/989
@@ -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
diff --git a/tests/generic/989.out b/tests/generic/989.out
new file mode 100644
index 00000000..32da0ce9
--- /dev/null
+++ b/tests/generic/989.out
@@ -0,0 +1,4 @@
+QA output created by 989
+swap files return ETXTBUSY
+copy_range: Text file busy
+copy_range: Text file busy
diff --git a/tests/generic/group b/tests/generic/group
index 20b95c14..4c100781 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -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
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 4/5] generic: copy_file_range bounds test
2019-05-26 8:45 [PATCH v2 0/5] fstests: copy_file_range() tests Amir Goldstein
` (2 preceding siblings ...)
2019-05-26 8:45 ` [PATCH v2 3/5] generic: copy_file_range swapfile test Amir Goldstein
@ 2019-05-26 8:45 ` Amir Goldstein
2019-05-29 2:16 ` Darrick J. Wong
2019-05-26 8:45 ` [PATCH v2 5/5] generic: cross-device copy_file_range test Amir Goldstein
2019-05-29 3:00 ` [PATCH v2 0/5] fstests: copy_file_range() tests Darrick J. Wong
5 siblings, 1 reply; 9+ messages in thread
From: Amir Goldstein @ 2019-05-26 8:45 UTC (permalink / raw)
To: Eryu Guan
Cc: Dave Chinner, Darrick J . Wong, fstests, linux-xfs, Dave Chinner
Test 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.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
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
diff --git a/tests/generic/990 b/tests/generic/990
new file mode 100755
index 00000000..5e2421b6
--- /dev/null
+++ b/tests/generic/990
@@ -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
diff --git a/tests/generic/990.out b/tests/generic/990.out
new file mode 100644
index 00000000..05d137de
--- /dev/null
+++ b/tests/generic/990.out
@@ -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
diff --git a/tests/generic/group b/tests/generic/group
index 4c100781..86802d54 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -552,3 +552,4 @@
547 auto quick log
988 auto quick copy_range
989 auto quick copy_range swap
+990 auto quick copy_range
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 4/5] generic: copy_file_range bounds test
2019-05-26 8:45 ` [PATCH v2 4/5] generic: copy_file_range bounds test Amir Goldstein
@ 2019-05-29 2:16 ` Darrick J. Wong
2019-05-29 5:30 ` Amir Goldstein
0 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2019-05-29 2:16 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Eryu Guan, Dave Chinner, fstests, linux-xfs, Dave Chinner
On Sun, May 26, 2019 at 11:45:34AM +0300, Amir Goldstein wrote:
> Test 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.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> 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
>
> diff --git a/tests/generic/990 b/tests/generic/990
> new file mode 100755
> index 00000000..5e2421b6
> --- /dev/null
> +++ b/tests/generic/990
> @@ -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
So, uh, is this going to cause test hangs on xfsprogs < 4.20?
--D
> +#
> +# 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
> diff --git a/tests/generic/990.out b/tests/generic/990.out
> new file mode 100644
> index 00000000..05d137de
> --- /dev/null
> +++ b/tests/generic/990.out
> @@ -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
> diff --git a/tests/generic/group b/tests/generic/group
> index 4c100781..86802d54 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -552,3 +552,4 @@
> 547 auto quick log
> 988 auto quick copy_range
> 989 auto quick copy_range swap
> +990 auto quick copy_range
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 4/5] generic: copy_file_range bounds test
2019-05-29 2:16 ` Darrick J. Wong
@ 2019-05-29 5:30 ` Amir Goldstein
0 siblings, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2019-05-29 5:30 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Eryu Guan, Dave Chinner, fstests, linux-xfs, Dave Chinner
On Wed, May 29, 2019 at 5:16 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> On Sun, May 26, 2019 at 11:45:34AM +0300, Amir Goldstein wrote:
> > Test 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.
> >
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > ---
> > 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
> >
> > diff --git a/tests/generic/990 b/tests/generic/990
> > new file mode 100755
> > index 00000000..5e2421b6
> > --- /dev/null
> > +++ b/tests/generic/990
> > @@ -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
>
> So, 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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 5/5] generic: cross-device copy_file_range test
2019-05-26 8:45 [PATCH v2 0/5] fstests: copy_file_range() tests Amir Goldstein
` (3 preceding siblings ...)
2019-05-26 8:45 ` [PATCH v2 4/5] generic: copy_file_range bounds test Amir Goldstein
@ 2019-05-26 8:45 ` Amir Goldstein
2019-05-29 3:00 ` [PATCH v2 0/5] fstests: copy_file_range() tests Darrick J. Wong
5 siblings, 0 replies; 9+ messages in thread
From: Amir Goldstein @ 2019-05-26 8:45 UTC (permalink / raw)
To: Eryu Guan
Cc: Dave Chinner, Darrick J . Wong, fstests, linux-xfs, Dave Chinner
Old 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.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
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
diff --git a/tests/generic/991 b/tests/generic/991
new file mode 100755
index 00000000..94266e89
--- /dev/null
+++ b/tests/generic/991
@@ -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
diff --git a/tests/generic/991.out b/tests/generic/991.out
new file mode 100644
index 00000000..19c22dfe
--- /dev/null
+++ b/tests/generic/991.out
@@ -0,0 +1,4 @@
+QA output created by 991
+md5sums after xdev copy:
+81615449a98aaaad8dc179b3bec87f38 TEST_DIR/test-991/file
+81615449a98aaaad8dc179b3bec87f38 SCRATCH_MNT/copy
diff --git a/tests/generic/group b/tests/generic/group
index 86802d54..bc5dac3b 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -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
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/5] fstests: copy_file_range() tests
2019-05-26 8:45 [PATCH v2 0/5] fstests: copy_file_range() tests Amir Goldstein
` (4 preceding siblings ...)
2019-05-26 8:45 ` [PATCH v2 5/5] generic: cross-device copy_file_range test Amir Goldstein
@ 2019-05-29 3:00 ` Darrick J. Wong
5 siblings, 0 replies; 9+ messages in thread
From: Darrick J. Wong @ 2019-05-29 3:00 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Eryu Guan, Dave Chinner, fstests, linux-xfs
On Sun, May 26, 2019 at 11:45:30AM +0300, Amir Goldstein wrote:
> 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.
The tests mostly look ok to me...
> 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.
> 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.
Grepping manpages? :D
--D
>
> 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/20190526061100.21761-1-amir73il@gmail.com/
>
> 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
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread