All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/5] Add copy_file_range() tests
@ 2016-12-08 18:49 ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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.

The last patch is a duplicate of a patch I already submitted for the
xfs_io utility.  It adds in fixes for the 'copy_range' command so error
checking can work and so some copies won't loop forever.

Thanks,
Anna

Anna Schumaker (5):
  generic/392: Add copy to new file test
  generic/393: Add small copies to new file test
  generic/394: Add copy test that overwrites data
  generic/395: Add a copy test for overwriting small amounts of data
  generic/396: Add a copy test for invalid input

 common/rc             |   6 +++
 tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/392.out |  26 +++++++++++++
 tests/generic/393     |  83 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/393.out |  16 ++++++++
 tests/generic/394     | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/394.out |  17 +++++++++
 tests/generic/395     |  87 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/395.out |  17 +++++++++
 tests/generic/396     |  68 +++++++++++++++++++++++++++++++++
 tests/generic/396.out |   8 ++++
 tests/generic/group   |   5 +++
 12 files changed, 535 insertions(+)
 create mode 100755 tests/generic/392
 create mode 100644 tests/generic/392.out
 create mode 100755 tests/generic/393
 create mode 100644 tests/generic/393.out
 create mode 100755 tests/generic/394
 create mode 100644 tests/generic/394.out
 create mode 100755 tests/generic/395
 create mode 100644 tests/generic/395.out
 create mode 100644 tests/generic/396
 create mode 100644 tests/generic/396.out

-- 
2.10.2


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 0/5] Add copy_file_range() tests
@ 2016-12-08 18:49 ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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.

The last patch is a duplicate of a patch I already submitted for the
xfs_io utility.  It adds in fixes for the 'copy_range' command so error
checking can work and so some copies won't loop forever.

Thanks,
Anna

Anna Schumaker (5):
  generic/392: Add copy to new file test
  generic/393: Add small copies to new file test
  generic/394: Add copy test that overwrites data
  generic/395: Add a copy test for overwriting small amounts of data
  generic/396: Add a copy test for invalid input

 common/rc             |   6 +++
 tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/392.out |  26 +++++++++++++
 tests/generic/393     |  83 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/393.out |  16 ++++++++
 tests/generic/394     | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/394.out |  17 +++++++++
 tests/generic/395     |  87 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/395.out |  17 +++++++++
 tests/generic/396     |  68 +++++++++++++++++++++++++++++++++
 tests/generic/396.out |   8 ++++
 tests/generic/group   |   5 +++
 12 files changed, 535 insertions(+)
 create mode 100755 tests/generic/392
 create mode 100644 tests/generic/392.out
 create mode 100755 tests/generic/393
 create mode 100644 tests/generic/393.out
 create mode 100755 tests/generic/394
 create mode 100644 tests/generic/394.out
 create mode 100755 tests/generic/395
 create mode 100644 tests/generic/395.out
 create mode 100644 tests/generic/396
 create mode 100644 tests/generic/396.out

-- 
2.10.2


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 1/5] generic/392: Add copy to new file test
  2016-12-08 18:49 ` Anna Schumaker
@ 2016-12-08 18:49   ` Anna Schumaker
  -1 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 common/rc             |   6 +++
 tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/392.out |  26 +++++++++++++
 tests/generic/group   |   1 +
 4 files changed, 135 insertions(+)
 create mode 100755 tests/generic/392
 create mode 100644 tests/generic/392.out

diff --git a/common/rc b/common/rc
index 8c99306..7c5d2a8 100644
--- a/common/rc
+++ b/common/rc
@@ -2054,6 +2054,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/392 b/tests/generic/392
new file mode 100755
index 0000000..466643a
--- /dev/null
+++ b/tests/generic/392
@@ -0,0 +1,102 @@
+#!/bin/bash
+# FS QA Test No. 392
+#
+# 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"
+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"
+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"
+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"
+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"
+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/392.out b/tests/generic/392.out
new file mode 100644
index 0000000..1c44b42
--- /dev/null
+++ b/tests/generic/392.out
@@ -0,0 +1,26 @@
+QA output created by 392
+Create the original file and then copy
+Original md5sums:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/copy
+Copy beginning of original file
+md5sums after copying beginning:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+cabe45dcc9ae5b66ba86600cca6b8ba8  TEST_DIR/test-392/beginning
+Copy middle of original file
+md5sums after copying middle:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+4197de9da5badfc302715486b82bcdf1  TEST_DIR/test-392/middle
+Copy end of original file
+md5sums after copying end:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+e68d4a150c4e42f4f9ea3ffe4c9cf4ed  TEST_DIR/test-392/end
+Copy beyond end of original file
+copy_range: Invalid argument
+md5sums after copying beyond:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+e68d4a150c4e42f4f9ea3ffe4c9cf4ed  TEST_DIR/test-392/beyond
+Copy creates hole in target file
+md5sums after creating hole:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+3ae9aef0992f8cb51c90c9a0ff2dd9d2  TEST_DIR/test-392/hole
diff --git a/tests/generic/group b/tests/generic/group
index 2c16bd1..1d6e7d2 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -394,3 +394,4 @@
 389 auto quick acl
 390 auto freeze stress dangerous
 391 auto quick rw
+392 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 1/5] generic/392: Add copy to new file test
@ 2016-12-08 18:49   ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 common/rc             |   6 +++
 tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/392.out |  26 +++++++++++++
 tests/generic/group   |   1 +
 4 files changed, 135 insertions(+)
 create mode 100755 tests/generic/392
 create mode 100644 tests/generic/392.out

diff --git a/common/rc b/common/rc
index 8c99306..7c5d2a8 100644
--- a/common/rc
+++ b/common/rc
@@ -2054,6 +2054,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/392 b/tests/generic/392
new file mode 100755
index 0000000..466643a
--- /dev/null
+++ b/tests/generic/392
@@ -0,0 +1,102 @@
+#!/bin/bash
+# FS QA Test No. 392
+#
+# 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"
+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"
+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"
+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"
+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"
+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/392.out b/tests/generic/392.out
new file mode 100644
index 0000000..1c44b42
--- /dev/null
+++ b/tests/generic/392.out
@@ -0,0 +1,26 @@
+QA output created by 392
+Create the original file and then copy
+Original md5sums:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/copy
+Copy beginning of original file
+md5sums after copying beginning:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+cabe45dcc9ae5b66ba86600cca6b8ba8  TEST_DIR/test-392/beginning
+Copy middle of original file
+md5sums after copying middle:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+4197de9da5badfc302715486b82bcdf1  TEST_DIR/test-392/middle
+Copy end of original file
+md5sums after copying end:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+e68d4a150c4e42f4f9ea3ffe4c9cf4ed  TEST_DIR/test-392/end
+Copy beyond end of original file
+copy_range: Invalid argument
+md5sums after copying beyond:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+e68d4a150c4e42f4f9ea3ffe4c9cf4ed  TEST_DIR/test-392/beyond
+Copy creates hole in target file
+md5sums after creating hole:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-392/file
+3ae9aef0992f8cb51c90c9a0ff2dd9d2  TEST_DIR/test-392/hole
diff --git a/tests/generic/group b/tests/generic/group
index 2c16bd1..1d6e7d2 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -394,3 +394,4 @@
 389 auto quick acl
 390 auto freeze stress dangerous
 391 auto quick rw
+392 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 2/5] generic/393: Add small copies to new file test
  2016-12-08 18:49 ` Anna Schumaker
@ 2016-12-08 18:49   ` Anna Schumaker
  -1 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/393     | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/393.out | 16 ++++++++++
 tests/generic/group   |  1 +
 3 files changed, 100 insertions(+)
 create mode 100755 tests/generic/393
 create mode 100644 tests/generic/393.out

diff --git a/tests/generic/393 b/tests/generic/393
new file mode 100755
index 0000000..21517aa
--- /dev/null
+++ b/tests/generic/393
@@ -0,0 +1,83 @@
+#!/bin/bash
+# FS QA Test No. 393
+#
+# 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"
+$XFS_IO_PROG -f -c "copy_range -s 1 -l 1      $testdir/file" "$testdir/b"
+$XFS_IO_PROG -f -c "copy_range -s 2 -l 1      $testdir/file" "$testdir/c"
+$XFS_IO_PROG -f -c "copy_range -s 3 -l 1      $testdir/file" "$testdir/d"
+$XFS_IO_PROG -f -c "copy_range -s 4 -l 1      $testdir/file" "$testdir/e"
+$XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
+$XFS_IO_PROG -f -c "copy_range -s 5 -l 1      $testdir/file" "$testdir/g"
+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/393.out b/tests/generic/393.out
new file mode 100644
index 0000000..763e301
--- /dev/null
+++ b/tests/generic/393.out
@@ -0,0 +1,16 @@
+QA output created by 393
+Create the original file and then copy
+Original md5sums:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-393/file
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-393/copy
+Small copies from various points in the original file
+copy_range: Invalid argument
+md5sums after small copies
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-393/file
+0cc175b9c0f1b6a831c399e269772661  TEST_DIR/test-393/a
+92eb5ffee6ae2fec3ad71c777531578f  TEST_DIR/test-393/b
+4a8a08f09d37b73795649038408b5f33  TEST_DIR/test-393/c
+8277e0910d750195b448797616e091ad  TEST_DIR/test-393/d
+e1671797c52e15f763380b45e841ec32  TEST_DIR/test-393/e
+2015eb238d706eceefc784742928054f  TEST_DIR/test-393/f
+d41d8cd98f00b204e9800998ecf8427e  TEST_DIR/test-393/g
diff --git a/tests/generic/group b/tests/generic/group
index 1d6e7d2..7b40a3d 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -395,3 +395,4 @@
 390 auto freeze stress dangerous
 391 auto quick rw
 392 auto quick copy
+393 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 2/5] generic/393: Add small copies to new file test
@ 2016-12-08 18:49   ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/393     | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/393.out | 16 ++++++++++
 tests/generic/group   |  1 +
 3 files changed, 100 insertions(+)
 create mode 100755 tests/generic/393
 create mode 100644 tests/generic/393.out

diff --git a/tests/generic/393 b/tests/generic/393
new file mode 100755
index 0000000..21517aa
--- /dev/null
+++ b/tests/generic/393
@@ -0,0 +1,83 @@
+#!/bin/bash
+# FS QA Test No. 393
+#
+# 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"
+$XFS_IO_PROG -f -c "copy_range -s 1 -l 1      $testdir/file" "$testdir/b"
+$XFS_IO_PROG -f -c "copy_range -s 2 -l 1      $testdir/file" "$testdir/c"
+$XFS_IO_PROG -f -c "copy_range -s 3 -l 1      $testdir/file" "$testdir/d"
+$XFS_IO_PROG -f -c "copy_range -s 4 -l 1      $testdir/file" "$testdir/e"
+$XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
+$XFS_IO_PROG -f -c "copy_range -s 5 -l 1      $testdir/file" "$testdir/g"
+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/393.out b/tests/generic/393.out
new file mode 100644
index 0000000..763e301
--- /dev/null
+++ b/tests/generic/393.out
@@ -0,0 +1,16 @@
+QA output created by 393
+Create the original file and then copy
+Original md5sums:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-393/file
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-393/copy
+Small copies from various points in the original file
+copy_range: Invalid argument
+md5sums after small copies
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-393/file
+0cc175b9c0f1b6a831c399e269772661  TEST_DIR/test-393/a
+92eb5ffee6ae2fec3ad71c777531578f  TEST_DIR/test-393/b
+4a8a08f09d37b73795649038408b5f33  TEST_DIR/test-393/c
+8277e0910d750195b448797616e091ad  TEST_DIR/test-393/d
+e1671797c52e15f763380b45e841ec32  TEST_DIR/test-393/e
+2015eb238d706eceefc784742928054f  TEST_DIR/test-393/f
+d41d8cd98f00b204e9800998ecf8427e  TEST_DIR/test-393/g
diff --git a/tests/generic/group b/tests/generic/group
index 1d6e7d2..7b40a3d 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -395,3 +395,4 @@
 390 auto freeze stress dangerous
 391 auto quick rw
 392 auto quick copy
+393 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 3/5] generic/394: Add copy test that overwrites data
  2016-12-08 18:49 ` Anna Schumaker
@ 2016-12-08 18:49   ` Anna Schumaker
  -1 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/394     | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/394.out |  17 +++++++++
 tests/generic/group   |   1 +
 3 files changed, 118 insertions(+)
 create mode 100755 tests/generic/394
 create mode 100644 tests/generic/394.out

diff --git a/tests/generic/394 b/tests/generic/394
new file mode 100755
index 0000000..8095644
--- /dev/null
+++ b/tests/generic/394
@@ -0,0 +1,100 @@
+#!/bin/bash
+# FS QA Test No. 394
+#
+# 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"
+$XFS_IO_PROG -f -c "copy_range -d 4000 -l 1000 $testdir/file" "$testdir/copy"
+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"
+$XFS_IO_PROG -f -c "copy_range -s 3000 -d 1000 -l 1000 $testdir/file" "$testdir/copy"
+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"
+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/394.out b/tests/generic/394.out
new file mode 100644
index 0000000..4121d24
--- /dev/null
+++ b/tests/generic/394.out
@@ -0,0 +1,17 @@
+QA output created by 394
+Create the original file and then copy
+Original md5sums:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/copy
+Swap beginning and end of original file
+md5sums after swapping beginning and end:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+5f4e111811dd9a810143c9db9bec6d80  TEST_DIR/test-394/copy
+Swap middle parts of original file
+md5sums after swapping middle:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+8c81889a5a50b311197110bcf769a695  TEST_DIR/test-394/copy
+Copy tail of original file onto copy
+md5sums after copying tail:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+e5fbacd993eaa5e80ebc2b14b969887d  TEST_DIR/test-394/copy
diff --git a/tests/generic/group b/tests/generic/group
index 7b40a3d..00f4f46 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -396,3 +396,4 @@
 391 auto quick rw
 392 auto quick copy
 393 auto quick copy
+394 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 3/5] generic/394: Add copy test that overwrites data
@ 2016-12-08 18:49   ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/394     | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/394.out |  17 +++++++++
 tests/generic/group   |   1 +
 3 files changed, 118 insertions(+)
 create mode 100755 tests/generic/394
 create mode 100644 tests/generic/394.out

diff --git a/tests/generic/394 b/tests/generic/394
new file mode 100755
index 0000000..8095644
--- /dev/null
+++ b/tests/generic/394
@@ -0,0 +1,100 @@
+#!/bin/bash
+# FS QA Test No. 394
+#
+# 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"
+$XFS_IO_PROG -f -c "copy_range -d 4000 -l 1000 $testdir/file" "$testdir/copy"
+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"
+$XFS_IO_PROG -f -c "copy_range -s 3000 -d 1000 -l 1000 $testdir/file" "$testdir/copy"
+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"
+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/394.out b/tests/generic/394.out
new file mode 100644
index 0000000..4121d24
--- /dev/null
+++ b/tests/generic/394.out
@@ -0,0 +1,17 @@
+QA output created by 394
+Create the original file and then copy
+Original md5sums:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/copy
+Swap beginning and end of original file
+md5sums after swapping beginning and end:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+5f4e111811dd9a810143c9db9bec6d80  TEST_DIR/test-394/copy
+Swap middle parts of original file
+md5sums after swapping middle:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+8c81889a5a50b311197110bcf769a695  TEST_DIR/test-394/copy
+Copy tail of original file onto copy
+md5sums after copying tail:
+e11fbace556cba26bf0076e74cab90a3  TEST_DIR/test-394/file
+e5fbacd993eaa5e80ebc2b14b969887d  TEST_DIR/test-394/copy
diff --git a/tests/generic/group b/tests/generic/group
index 7b40a3d..00f4f46 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -396,3 +396,4 @@
 391 auto quick rw
 392 auto quick copy
 393 auto quick copy
+394 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 4/5] generic/395: Add a copy test for overwriting small amounts of data
  2016-12-08 18:49 ` Anna Schumaker
@ 2016-12-08 18:49   ` Anna Schumaker
  -1 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/395     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/395.out | 17 ++++++++++
 tests/generic/group   |  1 +
 3 files changed, 105 insertions(+)
 create mode 100755 tests/generic/395
 create mode 100644 tests/generic/395.out

diff --git a/tests/generic/395 b/tests/generic/395
new file mode 100755
index 0000000..993a356
--- /dev/null
+++ b/tests/generic/395
@@ -0,0 +1,87 @@
+#!/bin/bash
+# FS QA Test No. 395
+#
+# 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"
+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"
+$XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
+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"
+$XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
+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"
+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/395.out b/tests/generic/395.out
new file mode 100644
index 0000000..f120056
--- /dev/null
+++ b/tests/generic/395.out
@@ -0,0 +1,17 @@
+QA output created by 395
+Create the original file and then copy
+Original md5sums:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/copy
+Swap beginning and end of original file
+md5sums after swapping beginning and end:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+32db1f6d06d15f7e38e1ab1c69da498a  TEST_DIR/test-395/copy
+Swap middle parts of original file
+md5sums after swapping middle:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+295228f3d82d344bbcf2f0030519c2ea  TEST_DIR/test-395/copy
+Copy tail of original file onto copy
+md5sums after copying tail:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+0c4aac952f72fa078e2f8419aca70b28  TEST_DIR/test-395/copy
diff --git a/tests/generic/group b/tests/generic/group
index 00f4f46..2b50ddb 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -397,3 +397,4 @@
 392 auto quick copy
 393 auto quick copy
 394 auto quick copy
+395 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 4/5] generic/395: Add a copy test for overwriting small amounts of data
@ 2016-12-08 18:49   ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/395     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/395.out | 17 ++++++++++
 tests/generic/group   |  1 +
 3 files changed, 105 insertions(+)
 create mode 100755 tests/generic/395
 create mode 100644 tests/generic/395.out

diff --git a/tests/generic/395 b/tests/generic/395
new file mode 100755
index 0000000..993a356
--- /dev/null
+++ b/tests/generic/395
@@ -0,0 +1,87 @@
+#!/bin/bash
+# FS QA Test No. 395
+#
+# 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"
+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"
+$XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
+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"
+$XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
+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"
+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/395.out b/tests/generic/395.out
new file mode 100644
index 0000000..f120056
--- /dev/null
+++ b/tests/generic/395.out
@@ -0,0 +1,17 @@
+QA output created by 395
+Create the original file and then copy
+Original md5sums:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/copy
+Swap beginning and end of original file
+md5sums after swapping beginning and end:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+32db1f6d06d15f7e38e1ab1c69da498a  TEST_DIR/test-395/copy
+Swap middle parts of original file
+md5sums after swapping middle:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+295228f3d82d344bbcf2f0030519c2ea  TEST_DIR/test-395/copy
+Copy tail of original file onto copy
+md5sums after copying tail:
+ab56b4d92b40713acc5af89985d4b786  TEST_DIR/test-395/file
+0c4aac952f72fa078e2f8419aca70b28  TEST_DIR/test-395/copy
diff --git a/tests/generic/group b/tests/generic/group
index 00f4f46..2b50ddb 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -397,3 +397,4 @@
 392 auto quick copy
 393 auto quick copy
 394 auto quick copy
+395 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 5/5] generic/396: Add a copy test for invalid input
  2016-12-08 18:49 ` Anna Schumaker
@ 2016-12-08 18:49   ` Anna Schumaker
  -1 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/396     | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/396.out |  8 ++++++
 tests/generic/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100644 tests/generic/396
 create mode 100644 tests/generic/396.out

diff --git a/tests/generic/396 b/tests/generic/396
new file mode 100644
index 0000000..c262070
--- /dev/null
+++ b/tests/generic/396
@@ -0,0 +1,68 @@
+#!/bin/bash
+# FS QA Test No. 396
+#
+# 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 file"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
+
+echo "source pos > source size:"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy"
+
+echo "target read-only"
+$XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
+
+echo "target append-only"
+$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/396.out b/tests/generic/396.out
new file mode 100644
index 0000000..4031883
--- /dev/null
+++ b/tests/generic/396.out
@@ -0,0 +1,8 @@
+QA output created by 396
+Create the original file
+source pos > source size:
+copy_range: Invalid argument
+target read-only
+copy_range: Bad file descriptor
+target append-only
+copy_range: Bad file descriptor
diff --git a/tests/generic/group b/tests/generic/group
index 2b50ddb..eee0f39 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -398,3 +398,4 @@
 393 auto quick copy
 394 auto quick copy
 395 auto quick copy
+396 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 5/5] generic/396: Add a copy test for invalid input
@ 2016-12-08 18:49   ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

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 <Anna.Schumaker@Netapp.com>
---
 tests/generic/396     | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/396.out |  8 ++++++
 tests/generic/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100644 tests/generic/396
 create mode 100644 tests/generic/396.out

diff --git a/tests/generic/396 b/tests/generic/396
new file mode 100644
index 0000000..c262070
--- /dev/null
+++ b/tests/generic/396
@@ -0,0 +1,68 @@
+#!/bin/bash
+# FS QA Test No. 396
+#
+# 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 file"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
+
+echo "source pos > source size:"
+$XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy"
+
+echo "target read-only"
+$XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
+
+echo "target append-only"
+$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
+
+#success, all done
+status=0
+exit
diff --git a/tests/generic/396.out b/tests/generic/396.out
new file mode 100644
index 0000000..4031883
--- /dev/null
+++ b/tests/generic/396.out
@@ -0,0 +1,8 @@
+QA output created by 396
+Create the original file
+source pos > source size:
+copy_range: Invalid argument
+target read-only
+copy_range: Bad file descriptor
+target append-only
+copy_range: Bad file descriptor
diff --git a/tests/generic/group b/tests/generic/group
index 2b50ddb..eee0f39 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -398,3 +398,4 @@
 393 auto quick copy
 394 auto quick copy
 395 auto quick copy
+396 auto quick copy
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 6/5] xfs_io: Improvements to copy_range return code handling
  2016-12-08 18:49 ` Anna Schumaker
@ 2016-12-08 18:49   ` Anna Schumaker
  -1 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

If copy_file_range() returns 0, then that means no data was copied.  We
should break out of the loop in this case to prevent looping
indefinitely.

Additionally, if an error is returned by copy_file_range() then we need
to print out the string form to be used by error checking tests in
xfstests.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
 io/copy_file_range.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/io/copy_file_range.c b/io/copy_file_range.c
index eddc634..161bdcf 100644
--- a/io/copy_file_range.c
+++ b/io/copy_file_range.c
@@ -49,8 +49,11 @@ copy_file_range(int fd, loff_t *src, loff_t *dst, size_t len)
 
 	do {
 		ret = syscall(__NR_copy_file_range, fd, src, file->fd, dst, len, 0);
-		if (ret == -1)
+		if (ret == -1) {
+			fprintf(stderr, _("copy_range: %s\n"), strerror(errno));
 			return errno;
+		} else if (ret == 0)
+			break;
 		len -= ret;
 	} while (len > 0);
 
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 6/5] xfs_io: Improvements to copy_range return code handling
@ 2016-12-08 18:49   ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 18:49 UTC (permalink / raw)
  To: fstests; +Cc: Anna.Schumaker, linux-nfs, hch

If copy_file_range() returns 0, then that means no data was copied.  We
should break out of the loop in this case to prevent looping
indefinitely.

Additionally, if an error is returned by copy_file_range() then we need
to print out the string form to be used by error checking tests in
xfstests.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
 io/copy_file_range.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/io/copy_file_range.c b/io/copy_file_range.c
index eddc634..161bdcf 100644
--- a/io/copy_file_range.c
+++ b/io/copy_file_range.c
@@ -49,8 +49,11 @@ copy_file_range(int fd, loff_t *src, loff_t *dst, size_t len)
 
 	do {
 		ret = syscall(__NR_copy_file_range, fd, src, file->fd, dst, len, 0);
-		if (ret == -1)
+		if (ret == -1) {
+			fprintf(stderr, _("copy_range: %s\n"), strerror(errno));
 			return errno;
+		} else if (ret == 0)
+			break;
 		len -= ret;
 	} while (len > 0);
 
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 5/5] generic/396: Add a copy test for invalid input
  2016-12-08 18:49   ` Anna Schumaker
  (?)
@ 2016-12-08 20:20   ` Darrick J. Wong
  2016-12-08 20:28       ` Anna Schumaker
  -1 siblings, 1 reply; 22+ messages in thread
From: Darrick J. Wong @ 2016-12-08 20:20 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: fstests, linux-nfs, hch

On Thu, Dec 08, 2016 at 01:49:08PM -0500, Anna Schumaker wrote:
> 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 <Anna.Schumaker@Netapp.com>
> ---
>  tests/generic/396     | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/396.out |  8 ++++++
>  tests/generic/group   |  1 +
>  3 files changed, 77 insertions(+)
>  create mode 100644 tests/generic/396
>  create mode 100644 tests/generic/396.out
> 
> diff --git a/tests/generic/396 b/tests/generic/396
> new file mode 100644
> index 0000000..c262070
> --- /dev/null
> +++ b/tests/generic/396
> @@ -0,0 +1,68 @@
> +#!/bin/bash
> +# FS QA Test No. 396
> +#
> +# 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 file"
> +$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
> +
> +echo "source pos > source size:"
> +$XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy"
> +
> +echo "target read-only"
> +$XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
> +
> +echo "target append-only"
> +$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"

Good start, though I can think of a few more things...

Copying when one or the other file arguments are directories/device files/etc.,
copies where pos < size but (pos + len) > size, copies where pos + len
overflow, overlapped src/dest ranges, and perhaps even copies across holes and
unwritten extents?

--D

> +
> +#success, all done
> +status=0
> +exit
> diff --git a/tests/generic/396.out b/tests/generic/396.out
> new file mode 100644
> index 0000000..4031883
> --- /dev/null
> +++ b/tests/generic/396.out
> @@ -0,0 +1,8 @@
> +QA output created by 396
> +Create the original file
> +source pos > source size:
> +copy_range: Invalid argument
> +target read-only
> +copy_range: Bad file descriptor
> +target append-only
> +copy_range: Bad file descriptor
> diff --git a/tests/generic/group b/tests/generic/group
> index 2b50ddb..eee0f39 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -398,3 +398,4 @@
>  393 auto quick copy
>  394 auto quick copy
>  395 auto quick copy
> +396 auto quick copy
> -- 
> 2.10.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 5/5] generic/396: Add a copy test for invalid input
  2016-12-08 20:20   ` Darrick J. Wong
@ 2016-12-08 20:28       ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 20:28 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-nfs, hch



On 12/08/2016 03:20 PM, Darrick J. Wong wrote:
> On Thu, Dec 08, 2016 at 01:49:08PM -0500, Anna Schumaker wrote:
>> 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 <Anna.Schumaker@Netapp.com>
>> ---
>>  tests/generic/396     | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>  tests/generic/396.out |  8 ++++++
>>  tests/generic/group   |  1 +
>>  3 files changed, 77 insertions(+)
>>  create mode 100644 tests/generic/396
>>  create mode 100644 tests/generic/396.out
>>
>> diff --git a/tests/generic/396 b/tests/generic/396
>> new file mode 100644
>> index 0000000..c262070
>> --- /dev/null
>> +++ b/tests/generic/396
>> @@ -0,0 +1,68 @@
>> +#!/bin/bash
>> +# FS QA Test No. 396
>> +#
>> +# 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 file"
>> +$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
>> +
>> +echo "source pos > source size:"
>> +$XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy"
>> +
>> +echo "target read-only"
>> +$XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
>> +
>> +echo "target append-only"
>> +$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
> 
> Good start, though I can think of a few more things...

Thanks!

> 
> Copying when one or the other file arguments are directories/device files/etc.,

Good suggestion, I didn't even think of that one.

> copies where pos < size but (pos + len) > size,

This is in the first patch as the "Copy beyond end of original file" test

> copies where pos + len
> overflow, overlapped src/dest ranges, and perhaps even copies across holes and
> unwritten extents?

These are also good suggestions.  I'll add them in!

Anna

> 
> --D
> 
>> +
>> +#success, all done
>> +status=0
>> +exit
>> diff --git a/tests/generic/396.out b/tests/generic/396.out
>> new file mode 100644
>> index 0000000..4031883
>> --- /dev/null
>> +++ b/tests/generic/396.out
>> @@ -0,0 +1,8 @@
>> +QA output created by 396
>> +Create the original file
>> +source pos > source size:
>> +copy_range: Invalid argument
>> +target read-only
>> +copy_range: Bad file descriptor
>> +target append-only
>> +copy_range: Bad file descriptor
>> diff --git a/tests/generic/group b/tests/generic/group
>> index 2b50ddb..eee0f39 100644
>> --- a/tests/generic/group
>> +++ b/tests/generic/group
>> @@ -398,3 +398,4 @@
>>  393 auto quick copy
>>  394 auto quick copy
>>  395 auto quick copy
>> +396 auto quick copy
>> -- 
>> 2.10.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe fstests" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 5/5] generic/396: Add a copy test for invalid input
@ 2016-12-08 20:28       ` Anna Schumaker
  0 siblings, 0 replies; 22+ messages in thread
From: Anna Schumaker @ 2016-12-08 20:28 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-nfs, hch



On 12/08/2016 03:20 PM, Darrick J. Wong wrote:
> On Thu, Dec 08, 2016 at 01:49:08PM -0500, Anna Schumaker wrote:
>> 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 <Anna.Schumaker@Netapp.com>
>> ---
>>  tests/generic/396     | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>  tests/generic/396.out |  8 ++++++
>>  tests/generic/group   |  1 +
>>  3 files changed, 77 insertions(+)
>>  create mode 100644 tests/generic/396
>>  create mode 100644 tests/generic/396.out
>>
>> diff --git a/tests/generic/396 b/tests/generic/396
>> new file mode 100644
>> index 0000000..c262070
>> --- /dev/null
>> +++ b/tests/generic/396
>> @@ -0,0 +1,68 @@
>> +#!/bin/bash
>> +# FS QA Test No. 396
>> +#
>> +# 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 file"
>> +$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
>> +
>> +echo "source pos > source size:"
>> +$XFS_IO_PROG -f -c "copy_range -s 1000 -l 100 $testdir/file" "$testdir/copy"
>> +
>> +echo "target read-only"
>> +$XFS_IO_PROG -r -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
>> +
>> +echo "target append-only"
>> +$XFS_IO_PROG -a -f -c "copy_range -s 0 -l 100 $testdir/file" "$testdir/copy"
> 
> Good start, though I can think of a few more things...

Thanks!

> 
> Copying when one or the other file arguments are directories/device files/etc.,

Good suggestion, I didn't even think of that one.

> copies where pos < size but (pos + len) > size,

This is in the first patch as the "Copy beyond end of original file" test

> copies where pos + len
> overflow, overlapped src/dest ranges, and perhaps even copies across holes and
> unwritten extents?

These are also good suggestions.  I'll add them in!

Anna

> 
> --D
> 
>> +
>> +#success, all done
>> +status=0
>> +exit
>> diff --git a/tests/generic/396.out b/tests/generic/396.out
>> new file mode 100644
>> index 0000000..4031883
>> --- /dev/null
>> +++ b/tests/generic/396.out
>> @@ -0,0 +1,8 @@
>> +QA output created by 396
>> +Create the original file
>> +source pos > source size:
>> +copy_range: Invalid argument
>> +target read-only
>> +copy_range: Bad file descriptor
>> +target append-only
>> +copy_range: Bad file descriptor
>> diff --git a/tests/generic/group b/tests/generic/group
>> index 2b50ddb..eee0f39 100644
>> --- a/tests/generic/group
>> +++ b/tests/generic/group
>> @@ -398,3 +398,4 @@
>>  393 auto quick copy
>>  394 auto quick copy
>>  395 auto quick copy
>> +396 auto quick copy
>> -- 
>> 2.10.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe fstests" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 0/5] Add copy_file_range() tests
  2016-12-08 18:49 ` Anna Schumaker
                   ` (6 preceding siblings ...)
  (?)
@ 2016-12-11  9:03 ` Amir Goldstein
  2016-12-11 18:34   ` Darrick J. Wong
  -1 siblings, 1 reply; 22+ messages in thread
From: Amir Goldstein @ 2016-12-11  9:03 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: fstests, linux-nfs, Christoph Hellwig, Darrick J. Wong

On Thu, Dec 8, 2016 at 8:49 PM, Anna Schumaker
<Anna.Schumaker@netapp.com> 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.
>

Hi Anna,

Both dedup and reflink have some generic tests to check for invalid cases
generic/{157,158}.
I wonder if there are any other dedup/reflink tests that should be
duplicated for copy_range. Darrick?
I also wonder if it would make sense to "deduplicate" some of these test
to repeat the same relevant checks for all 3 methods.


> The last patch is a duplicate of a patch I already submitted for the
> xfs_io utility.  It adds in fixes for the 'copy_range' command so error
> checking can work and so some copies won't loop forever.
>
> Thanks,
> Anna
>
> Anna Schumaker (5):
>   generic/392: Add copy to new file test
>   generic/393: Add small copies to new file test
>   generic/394: Add copy test that overwrites data
>   generic/395: Add a copy test for overwriting small amounts of data
>   generic/396: Add a copy test for invalid input
>
>  common/rc             |   6 +++
>  tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/392.out |  26 +++++++++++++
>  tests/generic/393     |  83 ++++++++++++++++++++++++++++++++++++++++
>  tests/generic/393.out |  16 ++++++++
>  tests/generic/394     | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/394.out |  17 +++++++++
>  tests/generic/395     |  87 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/395.out |  17 +++++++++
>  tests/generic/396     |  68 +++++++++++++++++++++++++++++++++
>  tests/generic/396.out |   8 ++++
>  tests/generic/group   |   5 +++
>  12 files changed, 535 insertions(+)
>  create mode 100755 tests/generic/392
>  create mode 100644 tests/generic/392.out
>  create mode 100755 tests/generic/393
>  create mode 100644 tests/generic/393.out
>  create mode 100755 tests/generic/394
>  create mode 100644 tests/generic/394.out
>  create mode 100755 tests/generic/395
>  create mode 100644 tests/generic/395.out
>  create mode 100644 tests/generic/396
>  create mode 100644 tests/generic/396.out
>
> --
> 2.10.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 0/5] Add copy_file_range() tests
  2016-12-11  9:03 ` [PATCH v4 0/5] Add copy_file_range() tests Amir Goldstein
@ 2016-12-11 18:34   ` Darrick J. Wong
  0 siblings, 0 replies; 22+ messages in thread
From: Darrick J. Wong @ 2016-12-11 18:34 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Anna Schumaker, fstests, linux-nfs, Christoph Hellwig

On Sun, Dec 11, 2016 at 11:03:50AM +0200, Amir Goldstein wrote:
> On Thu, Dec 8, 2016 at 8:49 PM, Anna Schumaker
> <Anna.Schumaker@netapp.com> 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.
> >
> 
> Hi Anna,
> 
> Both dedup and reflink have some generic tests to check for invalid cases
> generic/{157,158}.
> I wonder if there are any other dedup/reflink tests that should be
> duplicated for copy_range. Darrick?

Yes, feel free to borrow from g/157. :)

> I also wonder if it would make sense to "deduplicate" some of these test
> to repeat the same relevant checks for all 3 methods.

You could refactor them but for two tests (dedupe is its own weird
animal) I don't think it's worth the effort.

--D

> 
> 
> > The last patch is a duplicate of a patch I already submitted for the
> > xfs_io utility.  It adds in fixes for the 'copy_range' command so error
> > checking can work and so some copies won't loop forever.
> >
> > Thanks,
> > Anna
> >
> > Anna Schumaker (5):
> >   generic/392: Add copy to new file test
> >   generic/393: Add small copies to new file test
> >   generic/394: Add copy test that overwrites data
> >   generic/395: Add a copy test for overwriting small amounts of data
> >   generic/396: Add a copy test for invalid input
> >
> >  common/rc             |   6 +++
> >  tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/392.out |  26 +++++++++++++
> >  tests/generic/393     |  83 ++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/393.out |  16 ++++++++
> >  tests/generic/394     | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/394.out |  17 +++++++++
> >  tests/generic/395     |  87 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/395.out |  17 +++++++++
> >  tests/generic/396     |  68 +++++++++++++++++++++++++++++++++
> >  tests/generic/396.out |   8 ++++
> >  tests/generic/group   |   5 +++
> >  12 files changed, 535 insertions(+)
> >  create mode 100755 tests/generic/392
> >  create mode 100644 tests/generic/392.out
> >  create mode 100755 tests/generic/393
> >  create mode 100644 tests/generic/393.out
> >  create mode 100755 tests/generic/394
> >  create mode 100644 tests/generic/394.out
> >  create mode 100755 tests/generic/395
> >  create mode 100644 tests/generic/395.out
> >  create mode 100644 tests/generic/396
> >  create mode 100644 tests/generic/396.out
> >
> > --
> > 2.10.2
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 1/5] generic/392: Add copy to new file test
  2016-12-08 18:49   ` Anna Schumaker
  (?)
@ 2016-12-19 10:04   ` Eryu Guan
  2016-12-19 22:34     ` Darrick J. Wong
  -1 siblings, 1 reply; 22+ messages in thread
From: Eryu Guan @ 2016-12-19 10:04 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: fstests, linux-nfs, hch, darrick.wong

Hi Anna,

On Thu, Dec 08, 2016 at 01:49:04PM -0500, Anna Schumaker wrote:
> 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 <Anna.Schumaker@Netapp.com>

Sorry for the late review. I tested this patchset on 4.9 kernel and
xfs_io with your return code fix applied.

I met some common failures/behaviors in these tests, so I only comment
on this patch.

> ---
>  common/rc             |   6 +++
>  tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/392.out |  26 +++++++++++++
>  tests/generic/group   |   1 +
>  4 files changed, 135 insertions(+)
>  create mode 100755 tests/generic/392
>  create mode 100644 tests/generic/392.out
> 
> diff --git a/common/rc b/common/rc
> index 8c99306..7c5d2a8 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2054,6 +2054,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`
>  		;;

This is not able to _notrun as expect on a kernel without
copy_file_range syscall support, e.g. 4.4 kernel, xfs_io reports
"+copy_range: Function not implemented"

I think we need a new check on $testio after the case switch, e.g.

echo $testio | grep -q "not implemented" \
	&& _notrun "xfs_io $command is not implemented in kernel"

> diff --git a/tests/generic/392 b/tests/generic/392
> new file mode 100755
> index 0000000..466643a
> --- /dev/null
> +++ b/tests/generic/392
> @@ -0,0 +1,102 @@
> +#!/bin/bash
> +# FS QA Test No. 392
> +#
> +# 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"
> +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"
> +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"
> +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"

This didn't return EINVAL for me on xfs, ext4 and NFS, btrfs reported
EINVAL but it failed cmp and md5sum test at many other places. What is
the expected behavior?

generic/393 and generic/396 failed in a similar way, missing
"copy_range: Invalid argument" in the test output.

And seems copy_range -l option doesn't work well with xfs reflink
enabled? I saw many EINVALs when testing reflink enabled xfs, all these
5 tests failed. Kernel bug or xfs_io bug or we just want to _notrun on
reflink xfs?

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 1/5] generic/392: Add copy to new file test
  2016-12-19 10:04   ` Eryu Guan
@ 2016-12-19 22:34     ` Darrick J. Wong
  2016-12-20  3:26       ` Eryu Guan
  0 siblings, 1 reply; 22+ messages in thread
From: Darrick J. Wong @ 2016-12-19 22:34 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Anna Schumaker, fstests, linux-nfs, hch

On Mon, Dec 19, 2016 at 06:04:04PM +0800, Eryu Guan wrote:
> Hi Anna,
> 
> On Thu, Dec 08, 2016 at 01:49:04PM -0500, Anna Schumaker wrote:
> > 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 <Anna.Schumaker@Netapp.com>
> 
> Sorry for the late review. I tested this patchset on 4.9 kernel and
> xfs_io with your return code fix applied.
> 
> I met some common failures/behaviors in these tests, so I only comment
> on this patch.
> 
> > ---
> >  common/rc             |   6 +++
> >  tests/generic/392     | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/392.out |  26 +++++++++++++
> >  tests/generic/group   |   1 +
> >  4 files changed, 135 insertions(+)
> >  create mode 100755 tests/generic/392
> >  create mode 100644 tests/generic/392.out
> > 
> > diff --git a/common/rc b/common/rc
> > index 8c99306..7c5d2a8 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -2054,6 +2054,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`
> >  		;;
> 
> This is not able to _notrun as expect on a kernel without
> copy_file_range syscall support, e.g. 4.4 kernel, xfs_io reports
> "+copy_range: Function not implemented"
> 
> I think we need a new check on $testio after the case switch, e.g.
> 
> echo $testio | grep -q "not implemented" \
> 	&& _notrun "xfs_io $command is not implemented in kernel"
> 
> > diff --git a/tests/generic/392 b/tests/generic/392
> > new file mode 100755
> > index 0000000..466643a
> > --- /dev/null
> > +++ b/tests/generic/392
> > @@ -0,0 +1,102 @@
> > +#!/bin/bash
> > +# FS QA Test No. 392
> > +#
> > +# 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"
> > +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"
> > +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"
> > +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"
> 
> This didn't return EINVAL for me on xfs, ext4 and NFS, btrfs reported
> EINVAL but it failed cmp and md5sum test at many other places. What is
> the expected behavior?
>
> generic/393 and generic/396 failed in a similar way, missing
> "copy_range: Invalid argument" in the test output.
> 
> And seems copy_range -l option doesn't work well with xfs reflink
> enabled? I saw many EINVALs when testing reflink enabled xfs, all these
> 5 tests failed. Kernel bug or xfs_io bug or we just want to _notrun on
> reflink xfs?

Ugggggggghhhhhhhhh...

Prior to hch's vfs patch reorganizing vfs_copy_file_range to try clone first,
this happened[1]:

ret = -EOPNOTSUPP;
if (file_out->f_op->copy_file_range)
	ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
					      pos_out, len, flags);
if (ret == -EOPNOTSUPP)
	ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
			len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);

Note that copy_file_range pointed to XFS's clone_range implementation,
so if you pass in an offset/length that aren't block aligned, the clone
code returns EINVAL and ... we pass that out to userspace instead of
falling back.

Now it does this[2]:

if (file_in->f_op->clone_file_range) {
	ret = file_in->f_op->clone_file_range(file_in, pos_in,
			file_out, pos_out, len);
	if (ret == 0) {
		ret = len;
		goto done;
	}
}

if (file_out->f_op->copy_file_range) {
	ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
					      pos_out, len, flags);
	if (ret != -EOPNOTSUPP)
		goto done;
}

ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
		len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);

XFS removed the copy_file_range pointer, so therefore we'll try to
reflink the range and if that doesn't succeed we'll fall back to
whatever do_splice_direct does.  All those EINVALs should go away
shortly, at least on reflink-XFS.

--D

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/read_write.c?id=ffecee4f2442bb8cb6b34c3335fef4eb50c22fdd#n1545
[2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/read_write.c#n1543

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 1/5] generic/392: Add copy to new file test
  2016-12-19 22:34     ` Darrick J. Wong
@ 2016-12-20  3:26       ` Eryu Guan
  0 siblings, 0 replies; 22+ messages in thread
From: Eryu Guan @ 2016-12-20  3:26 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Anna Schumaker, fstests, linux-nfs, hch

On Mon, Dec 19, 2016 at 02:34:47PM -0800, Darrick J. Wong wrote:
> > 
> > And seems copy_range -l option doesn't work well with xfs reflink
> > enabled? I saw many EINVALs when testing reflink enabled xfs, all these
> > 5 tests failed. Kernel bug or xfs_io bug or we just want to _notrun on
> > reflink xfs?
> 
> Ugggggggghhhhhhhhh...
> 
> Prior to hch's vfs patch reorganizing vfs_copy_file_range to try clone first,
> this happened[1]:
> 
> ret = -EOPNOTSUPP;
> if (file_out->f_op->copy_file_range)
> 	ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
> 					      pos_out, len, flags);
> if (ret == -EOPNOTSUPP)
> 	ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
> 			len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
> 
> Note that copy_file_range pointed to XFS's clone_range implementation,
> so if you pass in an offset/length that aren't block aligned, the clone
> code returns EINVAL and ... we pass that out to userspace instead of
> falling back.
> 
> Now it does this[2]:
> 
> if (file_in->f_op->clone_file_range) {
> 	ret = file_in->f_op->clone_file_range(file_in, pos_in,
> 			file_out, pos_out, len);
> 	if (ret == 0) {
> 		ret = len;
> 		goto done;
> 	}
> }
> 
> if (file_out->f_op->copy_file_range) {
> 	ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out,
> 					      pos_out, len, flags);
> 	if (ret != -EOPNOTSUPP)
> 		goto done;
> }
> 
> ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
> 		len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);
> 
> XFS removed the copy_file_range pointer, so therefore we'll try to
> reflink the range and if that doesn't succeed we'll fall back to
> whatever do_splice_direct does.  All those EINVALs should go away
> shortly, at least on reflink-XFS.

Good to know, thanks for the explanation!

Eryu

> 
> --D
> 
> [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/read_write.c?id=ffecee4f2442bb8cb6b34c3335fef4eb50c22fdd#n1545
> [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/read_write.c#n1543
> 
> > 
> > Thanks,
> > Eryu
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-12-20  3:26 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-08 18:49 [PATCH v4 0/5] Add copy_file_range() tests Anna Schumaker
2016-12-08 18:49 ` Anna Schumaker
2016-12-08 18:49 ` [PATCH v4 1/5] generic/392: Add copy to new file test Anna Schumaker
2016-12-08 18:49   ` Anna Schumaker
2016-12-19 10:04   ` Eryu Guan
2016-12-19 22:34     ` Darrick J. Wong
2016-12-20  3:26       ` Eryu Guan
2016-12-08 18:49 ` [PATCH v4 2/5] generic/393: Add small copies " Anna Schumaker
2016-12-08 18:49   ` Anna Schumaker
2016-12-08 18:49 ` [PATCH v4 3/5] generic/394: Add copy test that overwrites data Anna Schumaker
2016-12-08 18:49   ` Anna Schumaker
2016-12-08 18:49 ` [PATCH v4 4/5] generic/395: Add a copy test for overwriting small amounts of data Anna Schumaker
2016-12-08 18:49   ` Anna Schumaker
2016-12-08 18:49 ` [PATCH v4 5/5] generic/396: Add a copy test for invalid input Anna Schumaker
2016-12-08 18:49   ` Anna Schumaker
2016-12-08 20:20   ` Darrick J. Wong
2016-12-08 20:28     ` Anna Schumaker
2016-12-08 20:28       ` Anna Schumaker
2016-12-08 18:49 ` [PATCH v4 6/5] xfs_io: Improvements to copy_range return code handling Anna Schumaker
2016-12-08 18:49   ` Anna Schumaker
2016-12-11  9:03 ` [PATCH v4 0/5] Add copy_file_range() tests Amir Goldstein
2016-12-11 18:34   ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.