From 6c668dc133af7d374790c1da666a701e21682a35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Sat, 23 Aug 2025 18:53:17 +0100 Subject: [PATCH] tests: cp: ensure copy offload is not disabled for sparse files Related to commits v9.1-109-g879d2180d and v9.7-248-g306de6c26 * tests/cp/sparse-perf.sh: This edge case was missed a couple of times, so add a test to ensure we attempt copy offload. --- tests/cp/sparse-perf.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/cp/sparse-perf.sh b/tests/cp/sparse-perf.sh index 8f737f798d..5a283c1fe6 100755 --- a/tests/cp/sparse-perf.sh +++ b/tests/cp/sparse-perf.sh @@ -18,8 +18,27 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ cp +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/tests/other-fs-tmpdir" + +# Create a sparse file on another partition to avoid reflinking +# thus exercising more copy logic + +other_partition_sparse=$other_partition_tmpdir/k +printf x > $other_partition_sparse || framework_failure_ +truncate -s1M $other_partition_sparse || framework_failure_ + +# cp should not disable anything by default, even for sparse files. For e.g. +# copy offload is an important performance improvement for sparse files on NFS. +cp --debug $other_partition_sparse k2 >cp.out || fail=1 +cmp $other_partition_sparse k2 || fail=1 +grep ': avoided' cp.out && { cat cp.out; fail=1; } + + + +# Create a large-but-sparse file on the current partition. +# We disable relinking below, thus verifying SEEK_HOLE support -# Create a large-but-sparse file. timeout 10 truncate -s1T f || skip_ "unable to create a 1 TiB sparse file" -- 2.47.3