mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 03:12:48 +02:00
tests: avoid reflinks when testing SEEK_DATA logic
This better tests the SEEK_HOLE logic which replaced the original fiemap hole identification logic. Also it avoids a false failure in sparse-2.sh on reflink supporting file systems, where we try to correlate the file sizes produced by cp and dd. * tests/cp/sparse-2.sh: s/cp/cp --reflink=never/ * tests/cp/sparse-extents-2.sh: Likewise. * tests/cp/sparse-extents.sh: Likewise. * tests/cp/sparse-perf.sh: Likewise. * tests/cp/sparse.sh: Likewise. Fixes https://github.com/coreutils/coreutils/issues/54
This commit is contained in:
@@ -32,7 +32,7 @@ dd bs=1k seek=128 of=k < /dev/null || framework_failure_
|
||||
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
|
||||
@@ -48,7 +48,7 @@ dd bs=1k seek=1 of=k count=255 < /dev/zero || framework_failure_
|
||||
# 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.
|
||||
|
||||
@@ -74,9 +74,10 @@ for i in $(seq 1 2 21); do
|
||||
|
||||
# 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
|
||||
|
||||
@@ -56,7 +56,7 @@ rm space.test
|
||||
|
||||
# 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
|
||||
@@ -68,12 +68,12 @@ 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_
|
||||
|
||||
@@ -28,7 +28,7 @@ timeout 10 truncate -s1T f ||
|
||||
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.
|
||||
|
||||
@@ -27,8 +27,12 @@ require_sparse_support_
|
||||
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
|
||||
@@ -51,22 +55,22 @@ for pattern in 1 0; do
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user