Skip to contentSkip to conversation

fstests: cross-vfsmount reflink changes

PATCH In review Josef Bacik 2 participants 6 messages Mar 24, 2022 – Mar 25, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover fstests: cross-vfsmount reflink changes

Hello,

We now allow cross-vfsmount reflinks, so adjust the tests that test to validate that these operations aren't allowed to validate that they are in fact allowed now. I've run this through our staging tree to validate that they pass on all of our configurations. Thanks,

Josef

Josef Bacik (3):
fstests: generic/373: change test to validate cross-vfsmount reflink
fstests: generic/374: validate cross-vfsmount dedupe
fstests: btrfs/029: change the cross vfsmount reflink test

 tests/btrfs/029       | 60 +++++++++++++++++++++++++------------------
 tests/btrfs/029.out   |  3 ++-
 tests/generic/373     |  8 +++---
 tests/generic/373.out |  2 +-
 tests/generic/374     |  5 ++--
 tests/generic/374.out |  3 ++-
 6 files changed, 47 insertions(+), 34 deletions(-)
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/3 fstests: generic/373: change test to validate cross-vfsmount reflink

We now allow cross-vfsmount reflinks so change the test to validate that cross-vfsmount reflinks work.

---
 tests/generic/373     | 8 ++++----
 tests/generic/373.out | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
tests/generic/373 +4 -4
index 2f68b24f..e85308c7 100755
@@ -4,7 +4,7 @@
 #
 # FS QA Test No. 373
 #
-# Check that cross-mountpoint reflink doesn't work.
+# Check that cross-mountpoint reflink works.
 #
 . ./common/preamble
 _begin_fstest auto quick clone
@@ -49,17 +49,17 @@ $MOUNT_PROG --bind $SCRATCH_MNT $otherdir
 echo "Create file"
 _pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
 
-filter_md5()
+filter_otherdir()
 {
 	_filter_scratch | sed -e "s,$otherdir,OTHER_DIR,g"
 }
 
 echo "Reflink one file to another"
-_cp_reflink $testdir/file $othertestdir/otherfiles 2>&1 | filter_md5
+_cp_reflink $testdir/file $othertestdir/otherfile 2>&1 | filter_otherdir
 
 echo "Check output"
 md5sum $testdir/file | _filter_scratch
-test -e $othertestdir/otherfile && echo "otherfile should not exist"
+md5sum $othertestdir/otherfile | filter_otherdir
 
 echo "Unmount otherdir"
 $UMOUNT_PROG $otherdir
tests/generic/373.out +1 -1
index 60f280fc..51f5c62b 100644
@@ -3,7 +3,7 @@ Format and mount
 Mount otherdir
 Create file
 Reflink one file to another
-cp: failed to clone 'OTHER_DIR/test-373/otherfiles' from 'SCRATCH_MNT/test-373/file': Invalid cross-device link
 Check output
 2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-373/file
+2d61aa54b58c2e94403fb092c3dbc027  OTHER_DIR/test-373/otherfile
 Unmount otherdir
Signature · 1 line
2.26.3
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] fstests: generic/373: change test to validate cross-vfsmount reflink

Quoted 8 lines · Josef Bacik

We now allow cross-vfsmount reflinks so change the test to validate that cross-vfsmount reflinks work.

---
 tests/generic/373     | 8 ++++----
 tests/generic/373.out | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

LGTM.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw

PATCH 2/3 fstests: generic/374: validate cross-vfsmount dedupe

In reply to Josef Bacik

We allow for cross-vfsmount dedupes now, change this test to validate dedupe works properly cross-vfsmount.

---
 tests/generic/374     | 5 +++--
 tests/generic/374.out | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
tests/generic/374 +3 -2
index d9f33bc3..f66d1397 100755
@@ -4,7 +4,7 @@
 #
 # FS QA Test No. 374
 #
-# Check that cross-mountpoint dedupe doesn't work.
+# Check that cross-mountpoint dedupe works
 #
 . ./common/preamble
 _begin_fstest auto quick clone dedupe
@@ -50,7 +50,8 @@ _pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
 _pwrite_byte 0x61 0 $sz $testdir/otherfile >> $seqres.full
 
 echo "Dedupe one file to another"
-_dedupe_range $testdir/file 0 $othertestdir/otherfile 0 $sz 2>&1 | _filter_dedupe_error
+_dedupe_range $testdir/file 0 $othertestdir/otherfile 0 $sz 2>&1 \
+	| _filter_xfs_io
 
 filter_md5()
 {
tests/generic/374.out +2 -1
index 3243ad3d..b62c64b4 100644
@@ -3,7 +3,8 @@ Format and mount
 Mount otherdir
 Create file
 Dedupe one file to another
-XFS_IOC_FILE_EXTENT_SAME: Invalid cross-device link
+deduped 65536/65536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 Check output
 2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-374/file
 2d61aa54b58c2e94403fb092c3dbc027  OTHER_DIR/test-374/otherfile
Signature · 1 line
2.26.3
#5 lore raw

PATCH 3/3 fstests: btrfs/029: change the cross vfsmount reflink test

In reply to Josef Bacik

We now allow cross vfsmount reflinks, change this test to make sure we pass the cross-vfsmount reflink.

---
 tests/btrfs/029     | 60 ++++++++++++++++++++++++++-------------------
 tests/btrfs/029.out |  3 ++-
 2 files changed, 37 insertions(+), 26 deletions(-)
tests/btrfs/029 +35 -25
index 1bdbc951..94886788 100755
@@ -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
tests/btrfs/029.out +2 -1
index f1c88780..c4971fcb 100644
@@ -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
Signature · 1 line
2.26.3