for append in no yes; do
test $append = yes && printf y >> k
for i in always never; do
- cp --sparse=$i k k2 || fail=1
+ cp --reflink=never --sparse=$i k k2 || fail=1
cmp k k2 || fail=1
done
done
# Currently, on my F14/ext4 desktop, this K file starts off with size 256KiB,
# (note that the K in the preceding test starts off with size 4KiB).
# cp from coreutils-8.9 with --sparse=always reduces the size to 32KiB.
-cp --sparse=always k k2 || fail=1
+cp --reflink=never --sparse=always k k2 || fail=1
if test $(stat -c %b k2) -ge $(stat -c %b k); then
# If not sparse, then double check by creating with dd
# as we're not guaranteed that seek will create a hole.
# Note there is an implicit sync performed by cp on Linux kernels
# before 2.6.39 to work around bugs in EXT4 and BTRFS.
+ # (this was removed in the release after coreutils-8.32).
# Note also the -s parameter to the filefrag commands below
# for the same reasons.
- cp --sparse=always j1 j2 || fail=1
+ cp --reflink=never --sparse=always j1 j2 || fail=1
cmp j1 j2 || fail_ "data loss i=$i j=$j"
if ! filefrag -vs j1 | grep -F extent >/dev/null; then
# Ensure we read a large empty file quickly
fallocate -l 300MiB empty.big || framework_failure_
-timeout 3 cp --sparse=always empty.big cp.test || fail=1
+timeout 3 cp --reflink=never --sparse=always empty.big cp.test || fail=1
test $(stat -c %s empty.big) = $(stat -c %s cp.test) || fail=1
rm empty.big cp.test
fi
# is smaller than the size, thus identifying the file as sparse.
# Note the '-l 1' case is an effective noop, and just checks
# a file with a trailing hole is copied correctly.
-for sparse_mode in always auto never; do
+for sparse_arg in always auto never; do
for alloc in '-l 4194304' '-l 1048576 -o 4194304' '-l 1'; do
dd count=10 if=/dev/urandom iflag=fullblock of=unwritten.withdata
truncate -s 2MiB unwritten.withdata || framework_failure_
fallocate $alloc -n unwritten.withdata || framework_failure_
- cp --sparse=$sparse_mode unwritten.withdata cp.test || fail=1
+ cp --reflink=never --sparse=$sparse_arg unwritten.withdata cp.test || fail=1
test $(stat -c %s unwritten.withdata) = $(stat -c %s cp.test) || fail=1
cmp unwritten.withdata cp.test || fail=1
rm unwritten.withdata cp.test || framework_failure_
skip_ "unable to create a 1 TiB sparse file"
# Nothing can read (much less write) that many bytes in so little time.
-timeout 10 cp f f2 || fail=1
+timeout 10 cp --reflink=never f f2 || fail=1
# Ensure that the sparse file copied through SEEK_DATA has the same size
# in bytes as the original.
size=$(expr 128 \* 1024 + 1)
dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure_
+# Avoid reflinking. We want to test hole navigation here.
+cp_no_reflink() {
+ cp --reflink=never "$@"
+}
-cp --sparse=always sparse copy || fail=1
+cp_no_reflink --sparse=always sparse copy || fail=1
# Ensure that the copy has the same block count as the original.
test $(stat --printf %b copy) -le $(stat --printf %b sparse) || fail=1
for n in 1 2 4 11 32 $maxn; do
parts=$(expr $maxn / $n)
- rm -f sparse.in
+ rm -f file.in
# Generate non sparse file for copying with alternating
# hole/data patterns of size n * $hole_size
for i in $(yes "$pattern" | head -n$parts); do
- dd iflag=fullblock if=$i of=sparse.in conv=notrunc oflag=append \
+ dd iflag=fullblock if=$i of=file.in conv=notrunc oflag=append \
bs=$hole_size count=$n status=none || framework_failure_
done
- cp --sparse=always sparse.in sparse.out || fail=1 # non sparse input
- cp --sparse=always sparse.out sparse.out2 || fail=1 # sparse input
+ cp_no_reflink --sparse=always file.in sparse.out || fail=1 # non sparse in
+ cp_no_reflink --sparse=always sparse.out sparse.out2 || fail=1 # sparse in
- cmp sparse.in sparse.out || fail=1
- cmp sparse.in sparse.out2 || fail=1
+ cmp file.in sparse.out || fail=1
+ cmp file.in sparse.out2 || fail=1
- ls -lsh sparse.*
+ ls -lsh file.in sparse.*
done
done