@@ -4690,6 +4690,29 @@ _get_file_block_size()
esac
}
+_test_congruent_file_oplen()
+{
+ local file="$1"
+ local alloc_unit=$(_get_file_block_size "$file")
+ local oplen="$2"
+
+ case $FSTYP in
+ nfs*|cifs|9p|virtiofs|ceph|glusterfs|overlay|pvfs2)
+ # Network filesystems don't know about (or tell the client
+ # about) the underlying file allocation unit and they generally
+ # pass the file IO request to the underlying filesystem, so we
+ # don't have anything to check here.
+ return
+ ;;
+ esac
+
+ if [ $alloc_unit -gt $oplen ]; then
+ return 1
+ fi
+ test $((oplen % alloc_unit)) -eq 0 || return 1
+ return 0
+}
+
# Given a file path and a byte length of a file operation under test, ensure
# that the length is an integer multiple of the file's allocation unit size.
# In other words, skip the test unless (oplen ≡ alloc_unit mod 0). This is
@@ -48,7 +48,13 @@ echo "Reflink past maximum file size in dest file (should fail)"
_reflink_range $testdir/file1 0 $testdir/file5 4611686018427322368 $len >> $seqres.full
echo "Reflink high offset to low offset"
-_reflink_range $testdir/file1 $bigoff_64k $testdir/file6 1048576 65535 >> $seqres.full
+oplen=1048576
+if _test_congruent_file_oplen $testdir $oplen; then
+ _reflink_range $testdir/file1 $bigoff_64k $testdir/file6 $oplen 65535 >> $seqres.full
+else
+ # If we can't do the ficlonerange test, fake it in the output file
+ $XFS_IO_PROG -f -c 'pwrite -S 0x61 1114110 1' $testdir/file6 >> $seqres.full
+fi
echo "Reflink past source file EOF (should fail)"
_reflink_range $testdir/file2 524288 $testdir/file7 0 1048576 >> $seqres.full