2017-03-17 19:57:05

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH v5 0/5] Add copy_file_range() tests

These tests exercise the copy_file_range() system call, and check copying
data to both a new file and overwriting data inside an existing file.

Sorry it took so long to get this version out. I forgot about these patches
after the last submission.

Thanks,
Anna


Anna Schumaker (5):
generic/416: Add copy to new file test
generic/417: Add small copies to new file test
generic/418: Add copy test that overwrites data
generic/419: Add a copy test for overwriting small amounts of data
generic/420: Add a copy test for invalid input

common/rc | 6 +++
tests/generic/416 | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/416.out | 26 +++++++++++++
tests/generic/417 | 83 ++++++++++++++++++++++++++++++++++++++++
tests/generic/417.out | 16 ++++++++
tests/generic/418 | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/418.out | 17 +++++++++
tests/generic/419 | 87 ++++++++++++++++++++++++++++++++++++++++++
tests/generic/419.out | 17 +++++++++
tests/generic/420 | 76 +++++++++++++++++++++++++++++++++++++
tests/generic/420.out | 12 ++++++
tests/generic/group | 5 +++
12 files changed, 547 insertions(+)
create mode 100755 tests/generic/416
create mode 100644 tests/generic/416.out
create mode 100755 tests/generic/417
create mode 100644 tests/generic/417.out
create mode 100755 tests/generic/418
create mode 100644 tests/generic/418.out
create mode 100755 tests/generic/419
create mode 100644 tests/generic/419.out
create mode 100644 tests/generic/420
create mode 100644 tests/generic/420.out

--
2.12.0



2017-03-17 20:04:26

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH v5 3/5] generic/418: Add copy test that overwrites data

Using copy to overwrite data in the destination file is perfectly valid,
so let's make sure this case works as expected.

Signed-off-by: Anna Schumaker <[email protected]>
---
tests/generic/418 | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/418.out | 17 +++++++++
tests/generic/group | 1 +
3 files changed, 118 insertions(+)
create mode 100755 tests/generic/418
create mode 100644 tests/generic/418.out

diff --git a/tests/generic/418 b/tests/generic/418
new file mode 100755
index 00000000..b64504e8
--- /dev/null
+++ b/tests/generic/418
@@ -0,0 +1,100 @@
+#!/bin/bash
+# FS QA Test No. 418
+#
+# Tests vfs_copy_file_range():
+# - Copy a file
+# - Use copy to swap data at beginning and end
+# - Use copy to swap data in the middle
+# - Use copy to simultaneously overwrite and append to destination file
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Netapp, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+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 15
+
+_cleanup()
+{
+ cd /
+ rm -rf $tmp.*
+}
+
+# get standard environment
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_xfs_io_command "copy_range"
+_require_test
+
+testdir=$TEST_DIR/test-$seq
+rm -rf $testdir
+mkdir $testdir
+rm -f $seqres.full
+
+echo "Create the original file and then copy"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
+cmp $testdir/file $testdir/copy
+echo "Original md5sums:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Swap beginning and end of original file"
+$XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/copy" 2>&1
+$XFS_IO_PROG -f -c "copy_range -d 4000 -l 1000 $testdir/file" "$testdir/copy" 2>&1
+cmp -n 1000 $testdir/file $testdir/copy 4000
+cmp -n 3000 $testdir/file $testdir/copy 1000 1000
+cmp -n 1000 $testdir/file $testdir/copy 0 4000
+echo "md5sums after swapping beginning and end:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Swap middle parts of original file"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 1000 $testdir/file" "$testdir/copy" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 3000 -d 1000 -l 1000 $testdir/file" "$testdir/copy" 2>&1
+cmp -n 1000 $testdir/file $testdir/copy 4000
+cmp -n 1000 $testdir/file $testdir/copy 3000 1000
+cmp -n 1000 $testdir/file $testdir/copy 2000 2000
+cmp -n 1000 $testdir/file $testdir/copy 1000 3000
+cmp -n 1000 $testdir/file $testdir/copy 0 4000
+echo "md5sums after swapping middle:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Copy tail of original file onto copy"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 4000 $testdir/file" "$testdir/copy" 2>&1
+cmp -n 1000 $testdir/file $testdir/copy 4000
+cmp -n 1000 $testdir/file $testdir/copy 3000 1000
+cmp -n 1000 $testdir/file $testdir/copy 2000 2000
+cmp -n 4000 $testdir/file $testdir/copy 1000 3000
+echo "md5sums after copying tail:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/418.out b/tests/generic/418.out
new file mode 100644
index 00000000..a0d1a4df
--- /dev/null
+++ b/tests/generic/418.out
@@ -0,0 +1,17 @@
+QA output created by 418
+Create the original file and then copy
+Original md5sums:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-418/file
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-418/copy
+Swap beginning and end of original file
+md5sums after swapping beginning and end:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-418/file
+5f4e111811dd9a810143c9db9bec6d80 TEST_DIR/test-418/copy
+Swap middle parts of original file
+md5sums after swapping middle:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-418/file
+8c81889a5a50b311197110bcf769a695 TEST_DIR/test-418/copy
+Copy tail of original file onto copy
+md5sums after copying tail:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-418/file
+e5fbacd993eaa5e80ebc2b14b969887d TEST_DIR/test-418/copy
diff --git a/tests/generic/group b/tests/generic/group
index 57ef9d22..f55b2b49 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -420,3 +420,4 @@
415 auto clone
416 auto quick copy
417 auto quick copy
+418 auto quick copy
--
2.12.0


2017-03-17 20:04:28

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH v5 4/5] generic/419: Add a copy test for overwriting small amounts of data

This test is similar to 345, except that it copies one byte at a time to
make sure that this case works as expected.

Signed-off-by: Anna Schumaker <[email protected]>
---
tests/generic/419 | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/419.out | 17 ++++++++++
tests/generic/group | 1 +
3 files changed, 105 insertions(+)
create mode 100755 tests/generic/419
create mode 100644 tests/generic/419.out

diff --git a/tests/generic/419 b/tests/generic/419
new file mode 100755
index 00000000..967412a2
--- /dev/null
+++ b/tests/generic/419
@@ -0,0 +1,87 @@
+#!/bin/bash
+# FS QA Test No. 419
+#
+# Tests vfs_copy_file_range():
+# - Copy a small file
+# - Use copy to swap data at beginning and end
+# - Use copy to swap data in the middle
+# - Use copy to swap data in a small file
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Netapp, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+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 15
+
+_cleanup()
+{
+ cd /
+ rm -rf $tmp.*
+}
+
+# get standard environment
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_xfs_io_command "copy_range"
+_require_test
+
+testdir=$TEST_DIR/test-$seq
+rm -rf $testdir
+mkdir $testdir
+rm -f $seqres.full
+
+echo "Create the original file and then copy"
+echo -n "abcde" > $testdir/file
+$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy" 2>&1
+cmp $testdir/file $testdir/copy
+echo "Original md5sums:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Swap beginning and end of original file"
+$XFS_IO_PROG -f -c "copy_range -s 0 -d 4 -l 1 $testdir/file" "$testdir/copy" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy" 2>&1
+echo -n "ebcda" | cmp $testdir/copy
+echo "md5sums after swapping beginning and end:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Swap middle parts of original file"
+$XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 1 $testdir/file" "$testdir/copy" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy" 2>&1
+echo -n "edcba" | cmp $testdir/copy
+echo "md5sums after swapping middle:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Copy tail of original file onto copy"
+$XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 4 $testdir/file" "$testdir/copy" 2>&1
+echo -n "edcbcde" | cmp $testdir/copy
+echo "md5sums after copying tail:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/419.out b/tests/generic/419.out
new file mode 100644
index 00000000..a5ab24db
--- /dev/null
+++ b/tests/generic/419.out
@@ -0,0 +1,17 @@
+QA output created by 419
+Create the original file and then copy
+Original md5sums:
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-419/file
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-419/copy
+Swap beginning and end of original file
+md5sums after swapping beginning and end:
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-419/file
+32db1f6d06d15f7e38e1ab1c69da498a TEST_DIR/test-419/copy
+Swap middle parts of original file
+md5sums after swapping middle:
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-419/file
+295228f3d82d344bbcf2f0030519c2ea TEST_DIR/test-419/copy
+Copy tail of original file onto copy
+md5sums after copying tail:
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-419/file
+0c4aac952f72fa078e2f8419aca70b28 TEST_DIR/test-419/copy
diff --git a/tests/generic/group b/tests/generic/group
index f55b2b49..6a2d3ee8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -421,3 +421,4 @@
416 auto quick copy
417 auto quick copy
418 auto quick copy
+419 auto quick copy
--
2.12.0


2017-03-17 20:04:26

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH v5 5/5] generic/420: Add a copy test for invalid input

This test passes invalid argumnt combinations to the copy_file_range()
system call to test that input is verified before attempting to copy.

Signed-off-by: Anna Schumaker <[email protected]>
---
tests/generic/420 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/420.out | 12 ++++++++
tests/generic/group | 1 +
3 files changed, 89 insertions(+)
create mode 100644 tests/generic/420
create mode 100644 tests/generic/420.out

diff --git a/tests/generic/420 b/tests/generic/420
new file mode 100644
index 00000000..703b4c13
--- /dev/null
+++ b/tests/generic/420
@@ -0,0 +1,76 @@
+#!/bin/bash
+# FS QA Test No. 420
+#
+# Tests vfs_copy_file_range() error checking
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Netapp, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+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 15
+
+_cleanup()
+{
+ cd /
+ rm -rf $tmp.*
+}
+
+# get standard environment
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_xfs_io_command "copy_range"
+_require_test
+
+testdir=$TEST_DIR/test-$seq
+rm -rf $testdir
+mkdir $testdir
+rm -f $seqres.full
+
+echo "Create the original files"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
+mknod $testdir/dev1 c 1 3
+mkfifo $testdir/fifo
+
+echo "Try to copy when source pos > source size"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy" 2>&1
+
+echo "Try to copy to a read-only file"
+$XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy" 2>&1
+
+echo "Try to copy to an append-only file"
+$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy" 2>&1
+
+echo "Try to copy to a device"
+$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/dev1" 2>&1
+
+echo "Try to copy to a fifo"
+$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/fifo" 2>&1
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/420.out b/tests/generic/420.out
new file mode 100644
index 00000000..b1da880a
--- /dev/null
+++ b/tests/generic/420.out
@@ -0,0 +1,12 @@
+QA output created by 420
+Create the original files
+Try to copy when source pos > source size
+copy_range: Invalid argument
+Try to copy to a read-only file
+copy_range: Bad file descriptor
+Try to copy to an append-only file
+copy_range: Bad file descriptor
+Try to copy to a device
+copy_range: Invalid argument
+Try to copy to a fifo
+copy_range: Invalid argument
diff --git a/tests/generic/group b/tests/generic/group
index 6a2d3ee8..69ab8f03 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -422,3 +422,4 @@
417 auto quick copy
418 auto quick copy
419 auto quick copy
+420 auto quick copy
--
2.12.0


2017-03-17 20:21:33

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH v5 1/5] generic/416: Add copy to new file test

This test copies data from various points in a source file to a new
file. This is useful for testing the basics of copy_file_range().

Signed-off-by: Anna Schumaker <[email protected]>
---
common/rc | 6 +++
tests/generic/416 | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/416.out | 26 +++++++++++++
tests/generic/group | 1 +
4 files changed, 135 insertions(+)
create mode 100755 tests/generic/416
create mode 100644 tests/generic/416.out

diff --git a/common/rc b/common/rc
index 109325df..98552a99 100644
--- a/common/rc
+++ b/common/rc
@@ -1976,6 +1976,12 @@ _require_xfs_io_command()
"chproj")
testio=`$XFS_IO_PROG -F -f -c "chproj 0" $testfile 2>&1`
;;
+ "copy_range")
+ testcopy=$TEST_DIR/$$.copy.xfs_io
+ $XFS_IO_PROG -F -f -c "pwrite 0 4k" $testfile 2>&1 > /dev/null
+ testio=`$XFS_IO_PROG -F -f -c "copy_range $testfile" $testcopy 2>&1`
+ rm -f $testcopy 2>&1 > /dev/null
+ ;;
"falloc" )
testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
;;
diff --git a/tests/generic/416 b/tests/generic/416
new file mode 100755
index 00000000..a669a6e7
--- /dev/null
+++ b/tests/generic/416
@@ -0,0 +1,102 @@
+#!/bin/bash
+# FS QA Test No. 416
+#
+# Tests vfs_copy_file_range():
+# - Copy a file
+# - Copy beginning of original to new file
+# - Copy middle of original to a new file
+# - Copy end of original to new file
+# - Copy middle of original to a new file, creating a hole
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Netapp, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+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 15
+
+_cleanup()
+{
+ cd /
+ rm -rf $tmp.*
+}
+
+# get standard environment
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_xfs_io_command "copy_range"
+_require_test
+
+testdir=$TEST_DIR/test-$seq
+rm -rf $testdir
+mkdir $testdir
+rm -f $seqres.full
+
+echo "Create the original file and then copy"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
+cmp $testdir/file $testdir/copy
+echo "Original md5sums:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Copy beginning of original file"
+$XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning" 2>&1
+cmp -n 1000 $testdir/file $testdir/beginning
+echo "md5sums after copying beginning:"
+md5sum $testdir/{file,beginning} | _filter_test_dir
+
+echo "Copy middle of original file"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 $testdir/file" "$testdir/middle" 2>&1
+cmp -n 3000 $testdir/file $testdir/middle 1000
+echo "md5sums after copying middle:"
+md5sum $testdir/{file,middle} | _filter_test_dir
+
+echo "Copy end of original file"
+$XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/end" 2>&1
+cmp -n 1000 $testdir/file $testdir/end 4000
+echo "md5sums after copying end:"
+md5sum $testdir/{file,end} | _filter_test_dir
+
+echo "Copy beyond end of original file"
+$XFS_IO_PROG -f -c "copy_range -s 4000 -l 2000 $testdir/file" "$testdir/beyond" 2>&1
+cmp -n 1000 $testdir/file $testdir/end 4000
+echo "md5sums after copying beyond:"
+md5sum $testdir/{file,beyond} | _filter_test_dir
+
+echo "Copy creates hole in target file"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 -d 1000 $testdir/file" "$testdir/hole" 2>&1
+cmp -n 3000 $testdir/file $testdir/hole 1000 1000
+echo "md5sums after creating hole:"
+md5sum $testdir/{file,hole} | _filter_test_dir
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/416.out b/tests/generic/416.out
new file mode 100644
index 00000000..107a156b
--- /dev/null
+++ b/tests/generic/416.out
@@ -0,0 +1,26 @@
+QA output created by 416
+Create the original file and then copy
+Original md5sums:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/file
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/copy
+Copy beginning of original file
+md5sums after copying beginning:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/file
+cabe45dcc9ae5b66ba86600cca6b8ba8 TEST_DIR/test-416/beginning
+Copy middle of original file
+md5sums after copying middle:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/file
+4197de9da5badfc302715486b82bcdf1 TEST_DIR/test-416/middle
+Copy end of original file
+md5sums after copying end:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/file
+e68d4a150c4e42f4f9ea3ffe4c9cf4ed TEST_DIR/test-416/end
+Copy beyond end of original file
+copy_range: Invalid argument
+md5sums after copying beyond:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/file
+e68d4a150c4e42f4f9ea3ffe4c9cf4ed TEST_DIR/test-416/beyond
+Copy creates hole in target file
+md5sums after creating hole:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-416/file
+3ae9aef0992f8cb51c90c9a0ff2dd9d2 TEST_DIR/test-416/hole
diff --git a/tests/generic/group b/tests/generic/group
index b510d410..9541fff5 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -418,3 +418,4 @@
413 auto quick
414 auto quick clone
415 auto clone
+416 auto quick copy
--
2.12.0


2017-03-17 20:21:33

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH v5 2/5] generic/417: Add small copies to new file test

This test copies single bytes from a source file into various new files
just to make sure that we can handle very small copies.

Signed-off-by: Anna Schumaker <[email protected]>
---
tests/generic/417 | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/417.out | 16 ++++++++++
tests/generic/group | 1 +
3 files changed, 100 insertions(+)
create mode 100755 tests/generic/417
create mode 100644 tests/generic/417.out

diff --git a/tests/generic/417 b/tests/generic/417
new file mode 100755
index 00000000..dde3f4d6
--- /dev/null
+++ b/tests/generic/417
@@ -0,0 +1,83 @@
+#!/bin/bash
+# FS QA Test No. 417
+#
+# Tests vfs_copy_file_range():
+# - Copy a small file
+# - Small copies from various points in the original file
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Netapp, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+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 15
+
+_cleanup()
+{
+ cd /
+ rm -rf $tmp.*
+}
+
+# get standard environment
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_xfs_io_command "copy_range"
+_require_test
+
+testdir=$TEST_DIR/test-$seq
+rm -rf $testdir
+mkdir $testdir
+rm -f $seqres.full
+
+echo "Create the original file and then copy"
+echo -n "abcde" > $testdir/file
+$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
+echo -n "abcde" | cmp $testdir/copy
+echo "Original md5sums:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
+echo "Small copies from various points in the original file"
+$XFS_IO_PROG -f -c "copy_range -s 0 -l 1 $testdir/file" "$testdir/a" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 1 -l 1 $testdir/file" "$testdir/b" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 2 -l 1 $testdir/file" "$testdir/c" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 3 -l 1 $testdir/file" "$testdir/d" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 4 -l 1 $testdir/file" "$testdir/e" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f" 2>&1
+$XFS_IO_PROG -f -c "copy_range -s 5 -l 1 $testdir/file" "$testdir/g" 2>&1
+echo -n "a" | cmp $testdir/a
+echo -n "b" | cmp $testdir/b
+echo -n "c" | cmp $testdir/c
+echo -n "d" | cmp $testdir/d
+echo -n "e" | cmp $testdir/e
+echo -en "\0e" | cmp $testdir/f
+echo -n "" | cmp $testdir/g
+echo "md5sums after small copies"
+md5sum $testdir/{file,a,b,c,d,e,f,g} | _filter_test_dir
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/417.out b/tests/generic/417.out
new file mode 100644
index 00000000..36c98478
--- /dev/null
+++ b/tests/generic/417.out
@@ -0,0 +1,16 @@
+QA output created by 417
+Create the original file and then copy
+Original md5sums:
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-417/file
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-417/copy
+Small copies from various points in the original file
+copy_range: Invalid argument
+md5sums after small copies
+ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-417/file
+0cc175b9c0f1b6a831c399e269772661 TEST_DIR/test-417/a
+92eb5ffee6ae2fec3ad71c777531578f TEST_DIR/test-417/b
+4a8a08f09d37b73795649038408b5f33 TEST_DIR/test-417/c
+8277e0910d750195b448797616e091ad TEST_DIR/test-417/d
+e1671797c52e15f763380b45e841ec32 TEST_DIR/test-417/e
+2015eb238d706eceefc784742928054f TEST_DIR/test-417/f
+d41d8cd98f00b204e9800998ecf8427e TEST_DIR/test-417/g
diff --git a/tests/generic/group b/tests/generic/group
index 9541fff5..57ef9d22 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -419,3 +419,4 @@
414 auto quick clone
415 auto clone
416 auto quick copy
+417 auto quick copy
--
2.12.0


2017-03-18 00:19:29

by Darrick J. Wong

[permalink] [raw]
Subject: Re: [PATCH v5 0/5] Add copy_file_range() tests

On Fri, Mar 17, 2017 at 03:52:28PM -0400, Anna Schumaker wrote:
> These tests exercise the copy_file_range() system call, and check copying
> data to both a new file and overwriting data inside an existing file.
>
> Sorry it took so long to get this version out. I forgot about these patches
> after the last submission.

Hooray, tests finally!

I had to bump the numbers up due to conflicts (it's usually best to pick
a really high number and let Eryu mvtest them to their real numbers),
but these mostly look ok.

However, I do see that something isn't triggering an EINVAL return code:

generic/816 - output mismatch (see /tmp/xfstests/results//generic/816.out.bad)
--- tests/generic/816.out 2017-03-17 14:46:21.064521899 -0700
+++ /tmp/xfstests/results//generic/816.out.bad 2017-03-17 14:58:15.848000000 -0700
@@ -16,7 +16,6 @@
e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-816/file
e68d4a150c4e42f4f9ea3ffe4c9cf4ed TEST_DIR/test-816/end
Copy beyond end of original file
-copy_range: Invalid argument
md5sums after copying beyond:
e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-816/file
e68d4a150c4e42f4f9ea3ffe4c9cf4ed TEST_DIR/test-816/beyond
...
(Run 'diff -u tests/generic/816.out /tmp/xfstests/results//generic/816.out.bad' to see the entire diff)
generic/817 - output mismatch (see /tmp/xfstests/results//generic/817.out.bad)
--- tests/generic/817.out 2017-03-17 14:47:02.916437143 -0700
+++ /tmp/xfstests/results//generic/817.out.bad 2017-03-17 14:58:17.168000000 -0700
@@ -4,7 +4,6 @@
ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-817/file
ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-817/copy
Small copies from various points in the original file
-copy_range: Invalid argument
md5sums after small copies
ab56b4d92b40713acc5af89985d4b786 TEST_DIR/test-817/file
0cc175b9c0f1b6a831c399e269772661 TEST_DIR/test-817/a
...
(Run 'diff -u tests/generic/817.out /tmp/xfstests/results//generic/817.out.bad' to see the entire diff)
generic/818 1s
generic/819 1s
generic/820 - output mismatch (see /tmp/xfstests/results//generic/820.out.bad)
--- tests/generic/820.out 2017-03-17 14:47:44.140338654 -0700
+++ /tmp/xfstests/results//generic/820.out.bad 2017-03-17 14:58:21.120000000 -0700
@@ -1,7 +1,6 @@
QA output created by 820
Create the original files
Try to copy when source pos > source size
-copy_range: Invalid argument
Try to copy to a read-only file
copy_range: Bad file descriptor
Try to copy to an append-only file
...
(Run 'diff -u tests/generic/820.out /tmp/xfstests/results//generic/820.out.bad' to see the entire diff)

Running 4.11-rc2 here with a ton of XFS patches, though these results
are from an FSTYP=ext4 run. FSTYP=xfs produces the same diff output.

--D

>
> Thanks,
> Anna
>
>
> Anna Schumaker (5):
> generic/416: Add copy to new file test
> generic/417: Add small copies to new file test
> generic/418: Add copy test that overwrites data
> generic/419: Add a copy test for overwriting small amounts of data
> generic/420: Add a copy test for invalid input
>
> common/rc | 6 +++
> tests/generic/416 | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/416.out | 26 +++++++++++++
> tests/generic/417 | 83 ++++++++++++++++++++++++++++++++++++++++
> tests/generic/417.out | 16 ++++++++
> tests/generic/418 | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/418.out | 17 +++++++++
> tests/generic/419 | 87 ++++++++++++++++++++++++++++++++++++++++++
> tests/generic/419.out | 17 +++++++++
> tests/generic/420 | 76 +++++++++++++++++++++++++++++++++++++
> tests/generic/420.out | 12 ++++++
> tests/generic/group | 5 +++
> 12 files changed, 547 insertions(+)
> create mode 100755 tests/generic/416
> create mode 100644 tests/generic/416.out
> create mode 100755 tests/generic/417
> create mode 100644 tests/generic/417.out
> create mode 100755 tests/generic/418
> create mode 100644 tests/generic/418.out
> create mode 100755 tests/generic/419
> create mode 100644 tests/generic/419.out
> create mode 100644 tests/generic/420
> create mode 100644 tests/generic/420.out
>
> --
> 2.12.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2017-03-20 05:25:01

by Eryu Guan

[permalink] [raw]
Subject: Re: [PATCH v5 0/5] Add copy_file_range() tests

On Fri, Mar 17, 2017 at 03:02:46PM -0700, Darrick J. Wong wrote:
> On Fri, Mar 17, 2017 at 03:52:28PM -0400, Anna Schumaker wrote:
> > These tests exercise the copy_file_range() system call, and check copying
> > data to both a new file and overwriting data inside an existing file.
> >
> > Sorry it took so long to get this version out. I forgot about these patches
> > after the last submission.
>
> Hooray, tests finally!
>
> I had to bump the numbers up due to conflicts (it's usually best to pick
> a really high number and let Eryu mvtest them to their real numbers),
> but these mostly look ok.

Usually the test numbers are not a problem, as long as the patchset is
based on latest master and there's no test number conflicts :)

Overall the tests look fine to me too.

>
> However, I do see that something isn't triggering an EINVAL return code:

Same results here, tested with xfs/ext4/btrfs on 4.11-rc2 kernel.

And another nitpick is the year in copyright, s/2016/2017/ ?

Thanks,
Eryu

2017-03-22 16:45:13

by Boaz Harrosh

[permalink] [raw]
Subject: Re: [PATCH v5 2/5] generic/417: Add small copies to new file test

On 03/17/2017 09:52 PM, Anna Schumaker wrote:
> This test copies single bytes from a source file into various new files
> just to make sure that we can handle very small copies.
>

Sorry for not following closely, but how is this supposed to work, I know that
for FSs that support it a copy_file_range is supported by clone_file_range.
But usually there are fs-block alignment restrictions on clone_file_range.

Does the VFS do the switch from fs->clone to generic-copy, or is the FS
suppose to call the generic-copy?

Thanks
Boaz

> Signed-off-by: Anna Schumaker <[email protected]>
> ---
> tests/generic/417 | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/417.out | 16 ++++++++++
> tests/generic/group | 1 +
> 3 files changed, 100 insertions(+)
> create mode 100755 tests/generic/417
> create mode 100644 tests/generic/417.out
>
> diff --git a/tests/generic/417 b/tests/generic/417
> new file mode 100755
> index 00000000..dde3f4d6
> --- /dev/null
> +++ b/tests/generic/417
> @@ -0,0 +1,83 @@
> +#!/bin/bash
> +# FS QA Test No. 417
> +#
> +# Tests vfs_copy_file_range():
> +# - Copy a small file
> +# - Small copies from various points in the original file
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2016 Netapp, Inc. All rights reserved.
<snip>



2017-05-02 22:17:27

by Darrick J. Wong

[permalink] [raw]
Subject: Re: [PATCH v5 0/5] Add copy_file_range() tests

On Mon, Mar 20, 2017 at 01:24:57PM +0800, Eryu Guan wrote:
> On Fri, Mar 17, 2017 at 03:02:46PM -0700, Darrick J. Wong wrote:
> > On Fri, Mar 17, 2017 at 03:52:28PM -0400, Anna Schumaker wrote:
> > > These tests exercise the copy_file_range() system call, and check copying
> > > data to both a new file and overwriting data inside an existing file.
> > >
> > > Sorry it took so long to get this version out. I forgot about these patches
> > > after the last submission.
> >
> > Hooray, tests finally!
> >
> > I had to bump the numbers up due to conflicts (it's usually best to pick
> > a really high number and let Eryu mvtest them to their real numbers),
> > but these mostly look ok.
>
> Usually the test numbers are not a problem, as long as the patchset is
> based on latest master and there's no test number conflicts :)
>
> Overall the tests look fine to me too.
>
> >
> > However, I do see that something isn't triggering an EINVAL return code:
>
> Same results here, tested with xfs/ext4/btrfs on 4.11-rc2 kernel.
>
> And another nitpick is the year in copyright, s/2016/2017/ ?

Another month, another kernel release... can we please get these tests
fixed and integrated?

--D

>
> Thanks,
> Eryu
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2017-05-03 12:56:13

by Olga Kornievskaia

[permalink] [raw]
Subject: Re: [PATCH v5 0/5] Add copy_file_range() tests

On Tue, May 2, 2017 at 6:16 PM, Darrick J. Wong <[email protected]> wrote:
> On Mon, Mar 20, 2017 at 01:24:57PM +0800, Eryu Guan wrote:
>> On Fri, Mar 17, 2017 at 03:02:46PM -0700, Darrick J. Wong wrote:
>> > On Fri, Mar 17, 2017 at 03:52:28PM -0400, Anna Schumaker wrote:
>> > > These tests exercise the copy_file_range() system call, and check copying
>> > > data to both a new file and overwriting data inside an existing file.
>> > >
>> > > Sorry it took so long to get this version out. I forgot about these patches
>> > > after the last submission.
>> >
>> > Hooray, tests finally!
>> >
>> > I had to bump the numbers up due to conflicts (it's usually best to pick
>> > a really high number and let Eryu mvtest them to their real numbers),
>> > but these mostly look ok.
>>
>> Usually the test numbers are not a problem, as long as the patchset is
>> based on latest master and there's no test number conflicts :)
>>
>> Overall the tests look fine to me too.
>>
>> >
>> > However, I do see that something isn't triggering an EINVAL return code:
>>
>> Same results here, tested with xfs/ext4/btrfs on 4.11-rc2 kernel.
>>
>> And another nitpick is the year in copyright, s/2016/2017/ ?
>
> Another month, another kernel release... can we please get these tests
> fixed and integrated?
>

I'm curious when you say "testing with btrfs" does it mean NFS server
exporting btrfs or does it mean just local btrfs?

> --D
>
>>
>> Thanks,
>> Eryu
>> --
>> To unsubscribe from this list: send the line "unsubscribe fstests" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2017-05-03 15:49:44

by Darrick J. Wong

[permalink] [raw]
Subject: Re: [PATCH v5 0/5] Add copy_file_range() tests

On Wed, May 03, 2017 at 08:56:11AM -0400, Olga Kornievskaia wrote:
> On Tue, May 2, 2017 at 6:16 PM, Darrick J. Wong <[email protected]> wrote:
> > On Mon, Mar 20, 2017 at 01:24:57PM +0800, Eryu Guan wrote:
> >> On Fri, Mar 17, 2017 at 03:02:46PM -0700, Darrick J. Wong wrote:
> >> > On Fri, Mar 17, 2017 at 03:52:28PM -0400, Anna Schumaker wrote:
> >> > > These tests exercise the copy_file_range() system call, and check copying
> >> > > data to both a new file and overwriting data inside an existing file.
> >> > >
> >> > > Sorry it took so long to get this version out. I forgot about these patches
> >> > > after the last submission.
> >> >
> >> > Hooray, tests finally!
> >> >
> >> > I had to bump the numbers up due to conflicts (it's usually best to pick
> >> > a really high number and let Eryu mvtest them to their real numbers),
> >> > but these mostly look ok.
> >>
> >> Usually the test numbers are not a problem, as long as the patchset is
> >> based on latest master and there's no test number conflicts :)
> >>
> >> Overall the tests look fine to me too.
> >>
> >> >
> >> > However, I do see that something isn't triggering an EINVAL return code:
> >>
> >> Same results here, tested with xfs/ext4/btrfs on 4.11-rc2 kernel.
> >>
> >> And another nitpick is the year in copyright, s/2016/2017/ ?
> >
> > Another month, another kernel release... can we please get these tests
> > fixed and integrated?
> >
>
> I'm curious when you say "testing with btrfs" does it mean NFS server
> exporting btrfs or does it mean just local btrfs?

Local btrfs, xfs, and ext4.

--D

>
> > --D
> >
> >>
> >> Thanks,
> >> Eryu
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe fstests" in
> >> the body of a message to [email protected]
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html