generic/326: basic copy_file_range() correctness
PATCH 1/1 generic/326: basic copy_file_range() correctness
Add basic tests for the copy_file_range() syscall that's being developed. This relies on having added copy_file_range() support to xfs_io in xfsprogs.
This is a very rough draft. Feedback welcome!
--- tests/generic/326 | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/group | 1 + 2 files changed, 99 insertions(+) create mode 100755 tests/generic/326
tests/generic/326 new file +98 -0
@@ -0,0 +1,98 @@ +#! /bin/bash +# FS QA Test No. 326 +# +# Try to test the basic shared behaviour of the file copy offloading +# syscall. Avoid making assumptions about the capabilities of the +# underlying storage. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Red Hat, 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 -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +_supported_fs generic +_supported_os Linux +_require_test + +src="$TEST_DIR/src" +dst="$TEST_DIR/dst" +$XFS_IO_PROG -ftc "pwrite -S 0x12 0 128k" "$src" | _filter_xfs_io +od -x "$src" + +echo "extend destination file" +$XFS_IO_PROG -ftc "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" "$dst" \ + | _filter_xfs_io +od -x "$dst" + +echo "copy into previously written region" +$XFS_IO_PROG -ft -c "pwrite -S 0xef 0 128k" "$dst" \ + -c "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" \ + | _filter_xfs_io +od -x "$dst" + +echo "copy into fallocate" +$XFS_IO_PROG -ft -c "falloc 0 128k" "$dst" \ + -c "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" \ + | _filter_xfs_io +od -x "$dst" + +echo "copy from likely sparse source" +$XFS_IO_PROG -ft -c "pwrite -S 0x56 96k 32k" "$src" \ + -c "pwrite -S 0x34 0 32k" | _filter_xfs_io +$XFS_IO_PROG -ftc "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" "$dst" \ + | _filter_xfs_io +od -x "$dst" + +echo "source at eof" +$XFS_IO_PROG -ftc \ + "copy_file_range -i $src -s $((128 * 1024)) -t 0 $((128 * 1024))" \ + "$dst" | _filter_xfs_io + +echo "src or dst not regular files" +$XFS_IO_PROG -ftc "copy_file_range -i /dev/null 1" "$dst" | _filter_xfs_io +$XFS_IO_PROG -c "copy_file_range -i $src 1" "/dev/null" | _filter_xfs_io + +echo "region shouldn't overlap in one file" +$XFS_IO_PROG -c "copy_file_range -i $src 1" "$src" | _filter_xfs_io + +echo "unknown flags fail" +$XFS_IO_PROG -ftc \ + "copy_file_range -i $src -s 0 -t 0 4096 -F 0x40000000" "$dst" \ + | _filter_xfs_io + +status=0 +exit $status
tests/generic/group +1 -0
@@ -188,3 +188,4 @@ 323 auto aio stress 324 auto fsr quick 325 auto quick data log +326 auto quick
Signature · 1 line
2.1.0
Quoted 10 lines · Zach Brown
Add basic tests for the
copy_file_range()syscall that's being developed. This relies on having addedcopy_file_range()support toxfs_ioin xfsprogs.This is a very rough draft. Feedback welcome!
Signed-off-by Zach Brown <[email protected]>--- tests/generic/326 | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/group | 1 +
Missing the golden output file.
tests/generic/326 line 49
Quoted 6 lines
tests/generic/326 new file +6
-0+ +# real QA test starts here + +_supported_fs generic +_supported_os Linux +_require_test
_require_xfs_io_command copy_file_range
tests/generic/326 line 52
Quoted 3 lines
tests/generic/326 new file +3
-0+ +src="$TEST_DIR/src" +dst="$TEST_DIR/dst"
Seeing this is on the test device, the files may already exist so you should remove them to give us a known good starting point.
Also, add $seq to the filename so that we know what test created the files.
Quoted 1 line
+$XFS_IO_PROG -ftc "pwrite -S
0x120 128k" "$src" |_filter_xfs_io
Add a "-c fsync" to ensure the file is on disk.
Quoted 1 line
+od -x "$src"
I'd just md5sum the file; if there's a mismatch, the dev can then look at it in more detail...
tests/generic/326 line 58
Quoted 3 lines
tests/generic/326 new file +3
-0+echo "extend destination file" +$XFS_IO_PROG -ftc "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" "$dst" \ + | _filter_xfs_io
-t 0 128k ?
Also, the truncate of the destination file is not obvious here, which is another good reason to rm -rf to begin with.
tests/generic/326 line 65
Quoted 8 lines
tests/generic/326 new file +6
-0+od -x "$dst" +echo "copy into previously written region" +$XFS_IO_PROG -ft -c "pwrite -S 0xef 0 128k" "$dst" \ + -c "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" \ + | _filter_xfs_io +od -x "$dst"
The truncate makes this a write into a delalloc region.
Add a fsync after the write to make it a copy into a written region.
tests/generic/326 line 71
Quoted 5 lines
tests/generic/326 new file +5
-0+echo "copy into fallocate" +$XFS_IO_PROG -ft -c "falloc 0 128k" "$dst" \ + -c "copy_file_range -i $src -s 0 -t 0 $((128 * 1024))" \ + | _filter_xfs_io +od -x "$dst"
"copy into preallocated region"
tests/generic/326 line 75
Quoted 3 lines
tests/generic/326 new file +3
-0+echo "copy from likely sparse source" +$XFS_IO_PROG -ft -c "pwrite -S 0x56 96k 32k" "$src" \ + -c "pwrite -S 0x34 0 32k" | _filter_xfs_io
fsync.
tests/generic/326 line 83
Quoted 8 lines
+$XFS_IO_PROG -ftc "
copy_file_range-i $src -s 0 -t 0 $((128 * 1024))" "$dst" \tests/generic/326 new file +7
-0+ | _filter_xfs_io +od -x "$dst" + +echo "source at eof" +$XFS_IO_PROG -ftc \ + "copy_file_range -i $src -s $((128 * 1024)) -t 0 $((128 * 1024))" \ + "$dst" | _filter_xfs_io
What is this supposed to leave? An empty file? If so, md5sum will still verify that...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]