aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2022-03-24 16:24:34 -0400
committerEryu Guan <guaneryu@gmail.com>2022-04-10 23:25:22 +0800
commit866948e00073fd7781f287e894918859ddb5f35e (patch)
treeedc8869b0b5f1b0dfb436eed94b9928e9488033a
parent9e8dac56ff3089de7e345bdbfb547a0f2df53759 (diff)
downloadxfstests-dev-866948e00073fd7781f287e894918859ddb5f35e.tar.gz
btrfs/029: change the cross vfsmount reflink test
We now allow cross vfsmount reflinks, change this test to make sure we pass the cross-vfsmount reflink. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-xtests/btrfs/02960
-rw-r--r--tests/btrfs/029.out3
2 files changed, 37 insertions, 26 deletions
diff --git a/tests/btrfs/029 b/tests/btrfs/029
index 1bdbc951df..94886788c5 100755
--- a/tests/btrfs/029
+++ b/tests/btrfs/029
@@ -5,14 +5,15 @@
# FS QA Test No. 029
#
# Check if creating a sparse copy ("reflink") of a file on btrfs
-# expectedly fails when it's done between different filesystems or
-# different mount points of the same filesystem.
+# expectedly fails when it's done between different filesystems but
+# not for different mount points of the same filesystem.
#
# For both situations, these actions are executed:
# - Copy a file with the reflink=auto option.
# A normal copy should be created.
# - Copy a file with the reflink=always option. Should result in
-# error.
+# error for different file systems, but succeed for the same fs
+# but different mount points.
#
. ./common/preamble
_begin_fstest auto quick clone
@@ -31,38 +32,47 @@ _require_cp_reflink
reflink_test_dir=$TEST_DIR/test-$seq
rm -rf $reflink_test_dir
mkdir $reflink_test_dir
+orig_file=$SCRATCH_MNT/original
+copy_file=$reflink_test_dir/copy
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/original >> $seqres.full
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $orig_file >> $seqres.full
-_create_reflinks()
-{
- # auto reflink, should fall back to non-reflink
- rm -rf $2
- echo "reflink=auto:"
- cp --reflink=auto $1 $2
- md5sum $1 | _filter_testdir_and_scratch
- md5sum $2 | _filter_testdir_and_scratch
-
- # always reflink, should fail outright
- rm -rf $2
- echo "reflink=always:"
- cp --reflink=always $1 $2 >> $seqres.full 2>&1 || echo "cp reflink failed"
+echo "test reflinks across different devices"
+# auto reflink, should fall back to non-reflink
+rm -rf $copy_file
+echo "reflink=auto:"
+cp --reflink=auto $orig_file $copy_file
+md5sum $orig_file | _filter_testdir_and_scratch
+md5sum $copy_file | _filter_testdir_and_scratch
- # The failed target gets created with zero sizes by cp(1) version 8.32. But
- # in older cp(1) version 8.30 target file is not created when the
- # cp --reflink=always fails.
- ls $2 >> $seqres.full 2>&1
-}
+# always reflink, should fail outright
+rm -rf $copy_file
+echo "reflink=always:"
+cp --reflink=always $orig_file $copy_file >> $seqres.full 2>&1 || echo "cp reflink failed"
-echo "test reflinks across different devices"
-_create_reflinks $SCRATCH_MNT/original $reflink_test_dir/copy
+# The failed target gets created with zero sizes by cp(1) version 8.32. But in
+# older cp(1) version 8.30 target file is not created when the cp
+# --reflink=always fails.
+ls $copy_file >> $seqres.full 2>&1
echo "test reflinks across different mountpoints of same device"
rm -rf $reflink_test_dir/*
_mount $SCRATCH_DEV $reflink_test_dir
-_create_reflinks $SCRATCH_MNT/original $reflink_test_dir/copy
+
+echo "reflink=auto:"
+cp --reflink=auto $orig_file $copy_file
+md5sum $orig_file | _filter_testdir_and_scratch
+md5sum $copy_file | _filter_testdir_and_scratch
+
+# always reflink, should fail outright
+rm -rf $copy_file
+echo "reflink=always:"
+cp --reflink=always $orig_file $copy_file >> $seqres.full 2>&1 || echo "cp reflink failed"
+md5sum $orig_file | _filter_testdir_and_scratch
+md5sum $copy_file | _filter_testdir_and_scratch
+
$UMOUNT_PROG $reflink_test_dir
# success, all done
diff --git a/tests/btrfs/029.out b/tests/btrfs/029.out
index f1c8878076..c4971fcbb2 100644
--- a/tests/btrfs/029.out
+++ b/tests/btrfs/029.out
@@ -10,4 +10,5 @@ reflink=auto:
42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/original
42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-029/copy
reflink=always:
-cp reflink failed
+42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/original
+42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-029/copy