Skip to contentSkip to conversation

generic/564: fix copy_range -f availability test

PATCH In review Eric Sandeen 2 participants 2 messages Sep 12, 2019 – Sep 13, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/564: fix copy_range -f availability test

generic/564 wants to test for copy_range -f, but as it's implemented it calls copy_range with a length of zero which will silently return success from the VFS (at least on some kernels) even if the underlying fs doesn't support it.

So patch this up 2 ways; perform the test with an explicit length so it's not a no-op, and go ahead test copy_range w/o -f in the test first just to be on the safe side (and for clearer failure messages.)

---

common/rc +1 -1
index e0b087c1..66c7fd4d 100644
@@ -2109,7 +2109,7 @@ _require_xfs_io_command()
 		if [ "$param" == "-f" ]; then
 			# source file is the open destination file
 			testcopy=$testfile
-			copy_opts="0 -d 4k"
+			copy_opts="0 -d 4k -l 4k"
 		fi
 		$XFS_IO_PROG -F -f -c "pwrite 0 4k" $testfile > /dev/null 2>&1
 		testio=`$XFS_IO_PROG -F -f -c "copy_range $param $copy_opts" $testcopy 2>&1`
tests/generic/564 +2 -0
index ee1786cc..4958b3b5 100755
@@ -49,6 +49,8 @@ _require_loop
 # copy source, as an indication that the test can run without hanging
 # with large size argument and to avoid opening pipe in blocking mode.
 #
+# Test both basic copy_range and copy_range -f availability
+_require_xfs_io_command "copy_range"
 _require_xfs_io_command "copy_range" "-f"
 
 testdir="$TEST_DIR/test-$seq"
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Eric Sandeen

generic/564 wants to test for copy_range -f, but as it's implemented it calls copy_range with a length of zero which will silently return success from the VFS (at least on some kernels) even if the underlying fs doesn't support it.

Quoted 7 lines

So patch this up 2 ways; perform the test with an explicit length so it's not a no-op, and go ahead test copy_range w/o -f in the test first just to be on the safe side (and for clearer failure messages.)

---

Quoted 27 lines
common/rc +1 -1
index e0b087c1..66c7fd4d 100644
@@ -2109,7 +2109,7 @@ _require_xfs_io_command()
 		if [ "$param" == "-f" ]; then
 			# source file is the open destination file
 			testcopy=$testfile
-			copy_opts="0 -d 4k"
+			copy_opts="0 -d 4k -l 4k"
 		fi
 		$XFS_IO_PROG -F -f -c "pwrite 0 4k" $testfile > /dev/null 2>&1
 		testio=`$XFS_IO_PROG -F -f -c "copy_range $param $copy_opts" $testcopy 2>&1`
tests/generic/564 +2 -0
index ee1786cc..4958b3b5 100755
@@ -49,6 +49,8 @@ _require_loop
 # copy source, as an indication that the test can run without hanging
 # with large size argument and to avoid opening pipe in blocking mode.
 #
+# Test both basic copy_range and copy_range -f availability
+_require_xfs_io_command "copy_range"
 _require_xfs_io_command "copy_range" "-f"
 
 testdir="$TEST_DIR/test-$seq"