clonerange: test remapping the rainbow
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Apr 2019 21:56:28 +0000 (14:56 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 14 Apr 2019 11:21:52 +0000 (19:21 +0800)
Add some more clone range tests that missed various "wacky" combinations
of file state.  Specifically, we test reflinking into and out of rainbow
ranges (a mix of real, unwritten, hole, delalloc, and shared extents),
and also we test that we can correctly handle double-inode locking no
matter what order of inodes or the filesystem's locking rules.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 files changed:
common/reflink
tests/generic/540 [new file with mode: 0755]
tests/generic/540.out [new file with mode: 0644]
tests/generic/541 [new file with mode: 0755]
tests/generic/541.out [new file with mode: 0644]
tests/generic/542 [new file with mode: 0755]
tests/generic/542.out [new file with mode: 0644]
tests/generic/543 [new file with mode: 0755]
tests/generic/543.out [new file with mode: 0644]
tests/generic/544 [new file with mode: 0755]
tests/generic/544.out [new file with mode: 0644]
tests/generic/group

index 11561a762544157e85a308eec67bb3884d390381..598f0877bedc73681ffe95c259d8a0cd841a79ef 100644 (file)
@@ -14,9 +14,14 @@ _require_cp_reflink()
 # Can we reflink between arbitrary file sets?
 # i.e. if we reflink a->b and c->d, can we later share
 # blocks between b & c?
+_supports_arbitrary_fileset_reflink()
+{
+       test "$FSTYP" != "ocfs2"
+}
+
 _require_arbitrary_fileset_reflink()
 {
-       test "$FSTYP" = "ocfs2" && \
+       _supports_arbitrary_fileset_reflink ||
                _notrun "reflink between arbitrary file groups not supported in $FSTYP"
 }
 
diff --git a/tests/generic/540 b/tests/generic/540
new file mode 100755 (executable)
index 0000000..65a71f2
--- /dev/null
@@ -0,0 +1,92 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 540
+#
+# Ensuring that reflinking works when the destination range covers multiple
+# extents, some unwritten, some not:
+#
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - reflink across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs generic
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+blksz=65536
+nr=64
+filesize=$((blksz * nr))
+_pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2 >> $seqres.full
+_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+echo "reflink across the transition"
+roff=$((filesize / 4))
+rsz=$((filesize / 2))
+_weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
+
+# now reflink into the rainbow
+echo "before reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $testdir/file2 $roff $roff $rsz" $testdir/file3 >> $seqres.full
+_pwrite_byte 0x64 $roff $rsz $testdir/file3.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+echo "after reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/540.out b/tests/generic/540.out
new file mode 100644 (file)
index 0000000..1eb336e
--- /dev/null
@@ -0,0 +1,14 @@
+QA output created by 540
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-540/file1
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-540/file2
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-540/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-540/file3.chk
+reflink across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-540/file1
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-540/file2
+5d47954e2336b2547afde6e44d2f13cc  SCRATCH_MNT/test-540/file3
+5d47954e2336b2547afde6e44d2f13cc  SCRATCH_MNT/test-540/file3.chk
diff --git a/tests/generic/541 b/tests/generic/541
new file mode 100755 (executable)
index 0000000..e7e19be
--- /dev/null
@@ -0,0 +1,97 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 541
+#
+# Ensuring that reflinking works when the source range covers multiple
+# extents, some unwritten, some not:
+#
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - reflink across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs generic
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+blksz=65536
+nr=64
+filesize=$((blksz * nr))
+_pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2 >> $seqres.full
+_pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2.chk >> $seqres.full
+_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file2.chk | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+echo "reflink across the transition"
+roff=$((filesize / 4))
+rsz=$((filesize / 2))
+_weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
+
+# now reflink the rainbow
+echo "before reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $testdir/file3 $roff $roff $rsz" $testdir/file2 >> $seqres.full
+cp $testdir/file3.chk $testdir/file2.chk
+_pwrite_byte 0x64 0 $roff $testdir/file2.chk >> $seqres.full
+_pwrite_byte 0x64 $((roff + rsz)) $((filesize - (roff + rsz) )) $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+echo "after reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file2.chk | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/541.out b/tests/generic/541.out
new file mode 100644 (file)
index 0000000..e08ff87
--- /dev/null
@@ -0,0 +1,16 @@
+QA output created by 541
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-541/file1
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-541/file2
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-541/file2.chk
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-541/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-541/file3.chk
+reflink across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-541/file1
+51a300aae3a4b4eaa023876a397e01ef  SCRATCH_MNT/test-541/file2
+51a300aae3a4b4eaa023876a397e01ef  SCRATCH_MNT/test-541/file2.chk
+7bf7a779a0a54647b41753206c5218b1  SCRATCH_MNT/test-541/file3
+7bf7a779a0a54647b41753206c5218b1  SCRATCH_MNT/test-541/file3.chk
diff --git a/tests/generic/542 b/tests/generic/542
new file mode 100755 (executable)
index 0000000..c416ab6
--- /dev/null
@@ -0,0 +1,93 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 542
+#
+# Ensuring that reflinking works when the destination range covers multiple
+# extents, some unwritten, some not:
+#
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - reflink across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs generic
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+blksz=65536
+nr=64
+filesize=$((blksz * nr))
+_pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2 >> $seqres.full
+_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+echo "reflink across the transition"
+soff=$((filesize / 4))
+doff=$((filesize / 2))
+rsz=$((filesize / 2))
+_weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
+
+# now reflink into the rainbow
+echo "before reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $testdir/file2 $soff $doff $rsz" $testdir/file3 >> $seqres.full
+_pwrite_byte 0x64 $doff $rsz $testdir/file3.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+echo "after reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/542.out b/tests/generic/542.out
new file mode 100644 (file)
index 0000000..309ff0b
--- /dev/null
@@ -0,0 +1,14 @@
+QA output created by 542
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-542/file1
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-542/file2
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-542/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-542/file3.chk
+reflink across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-542/file1
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-542/file2
+52bb341f992de6ef4bf5e5d61177eddc  SCRATCH_MNT/test-542/file3
+52bb341f992de6ef4bf5e5d61177eddc  SCRATCH_MNT/test-542/file3.chk
diff --git a/tests/generic/543 b/tests/generic/543
new file mode 100755 (executable)
index 0000000..50a51f8
--- /dev/null
@@ -0,0 +1,97 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 543
+#
+# Ensuring that reflinking works when the source range covers multiple
+# extents, some unwritten, some not:
+#
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - reflink across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs generic
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+blksz=65536
+nr=64
+filesize=$((blksz * nr))
+_pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2 >> $seqres.full
+_pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2.chk >> $seqres.full
+_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file2.chk | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+echo "reflink across the transition"
+soff=$((filesize / 4))
+doff=$((filesize / 2))
+rsz=$((filesize / 2))
+_weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
+
+# now reflink the rainbow
+echo "before reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $testdir/file3 $soff $doff $rsz" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -c "truncate $doff" $testdir/file2.chk
+dd if=$testdir/file3.chk skip=$((soff / blksz)) count=$((rsz / blksz)) bs=$blksz >> $testdir/file2.chk 2> /dev/null
+_scratch_cycle_mount
+
+echo "Compare files"
+echo "after reflink" >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file2 >> $seqres.full
+$FILEFRAG_PROG -v $testdir/file3 >> $seqres.full
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+md5sum $testdir/file2.chk | _filter_scratch
+md5sum $testdir/file3 | _filter_scratch
+md5sum $testdir/file3.chk | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/543.out b/tests/generic/543.out
new file mode 100644 (file)
index 0000000..ebe677e
--- /dev/null
@@ -0,0 +1,16 @@
+QA output created by 543
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-543/file1
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-543/file2
+5a5221017d3ab8fd7583312a14d2ba80  SCRATCH_MNT/test-543/file2.chk
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-543/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-543/file3.chk
+reflink across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-543/file1
+d93123af536c8c012f866ea383a905ce  SCRATCH_MNT/test-543/file2
+d93123af536c8c012f866ea383a905ce  SCRATCH_MNT/test-543/file2.chk
+7bf7a779a0a54647b41753206c5218b1  SCRATCH_MNT/test-543/file3
+7bf7a779a0a54647b41753206c5218b1  SCRATCH_MNT/test-543/file3.chk
diff --git a/tests/generic/544 b/tests/generic/544
new file mode 100755 (executable)
index 0000000..96f28d8
--- /dev/null
@@ -0,0 +1,197 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 544
+#
+# Ensure that we can reflink from a file with a higher inode number to a lower
+# inode number and vice versa.  Mix it up by doing this test with inodes that
+# already share blocks and inodes that don't share blocks.  This tests both
+# double-inode locking order correctness as well as stressing things like ocfs2
+# which have per-inode sharing groups and therefore have to check that we don't
+# try to link data between disjoint sharing groups.
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs generic
+_require_scratch_reflink
+_require_cp_reflink
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+blksz=65536
+nr=2
+filesize=$((blksz * nr))
+testdir=$SCRATCH_MNT/test-$seq
+dummy_file=$testdir/dummy
+low_file=$testdir/low
+high_file=$testdir/high
+scenario=1
+mkdir $testdir
+
+# Return inode number
+inum() {
+       stat -c '%i' $1
+}
+
+# Create two test files, make $low_file the file with the lower inode
+# number, and make $high_file the file with the higher inode number.
+create_files() {
+       _pwrite_byte 0x60 0 $filesize $testdir/file1 >> $seqres.full
+       _pwrite_byte 0x61 0 $filesize $testdir/file2 >> $seqres.full
+       if [ "$(inum $testdir/file1)" -lt "$(inum $testdir/file2)" ]; then
+               mv $testdir/file1 $low_file
+               mv $testdir/file2 $high_file
+       else
+               mv $testdir/file2 $low_file
+               mv $testdir/file1 $high_file
+       fi
+}
+
+# Check md5sum of both files, but keep results sorted by inode order
+check_files() {
+       md5sum $low_file | _filter_scratch
+       md5sum $high_file | _filter_scratch
+}
+
+# Test reflinking data from the first file to the second file
+test_files() {
+       local src="$1"
+       local dest="$2"
+       local off=$((filesize / 2))
+       local sz=$((filesize / 2))
+
+       check_files
+       _reflink_range $src $off $dest $off $sz >> $seqres.full
+       _scratch_cycle_mount
+       check_files
+}
+
+# Make a file shared with a dummy file
+dummy_share() {
+       local which="$2"
+       test -z "$which" && which=1
+       local dummy=$dummy_file.$which
+
+       rm -f $dummy
+       _cp_reflink $1 $dummy
+}
+
+# Make two files share (different ranges) with a dummy file
+mutual_dummy_share() {
+       rm -f $dummy_file
+       _cp_reflink $1 $dummy_file
+       _reflink_range $2 0 $dummy_file $blksz $blksz >> $seqres.full
+}
+
+# Announce ourselves, remembering which scenario we've tried
+ann() {
+       echo "$scenario: $@" | tee -a $seqres.full
+       scenario=$((scenario + 1))
+}
+
+# Scenario 1: low to high, neither file shares
+ann "low to high, neither share"
+create_files
+test_files $low_file $high_file
+
+# Scenario 2: high to low, neither file shares
+ann "high to low, neither share"
+create_files
+test_files $high_file $low_file
+
+# Scenario 3: low to high, only source file shares
+ann "low to high, only source shares"
+create_files
+dummy_share $low_file
+test_files $low_file $high_file
+
+# Scenario 4: high to low, only source file shares
+ann "high to low, only source shares"
+create_files
+dummy_share $high_file
+test_files $high_file $low_file
+
+# Scenario 5: low to high, only dest file shares
+ann "low to high, only dest shares"
+create_files
+dummy_share $high_file
+test_files $low_file $high_file
+
+# Scenario 6: high to low, only dest file shares
+ann "high to low, only dest shares"
+create_files
+dummy_share $low_file
+test_files $high_file $low_file
+
+# Scenario 7: low to high, both files share with each other
+ann "low to high, both files share with each other"
+create_files
+_reflink_range $low_file 0 $high_file 0 $blksz >> $seqres.full
+test_files $low_file $high_file
+
+# Scenario 8: high to low, both files share with each other
+ann "high to low, both files share with each other"
+create_files
+_reflink_range $low_file 0 $high_file 0 $blksz >> $seqres.full
+test_files $high_file $low_file
+
+# Scenario 9: low to high, both files share but not with each other
+ann "low to high, both files share but not with each other"
+create_files
+# ocfs2 can only reflink between files sharing a refcount tree, so for
+# this test (and #10) we skip the dummy file because we'd rather not split
+# the test code just to mask off the /one/ weird fs like this...
+if _supports_arbitrary_fileset_reflink; then
+       dummy_share $low_file 1
+       dummy_share $high_file 2
+fi
+test_files $low_file $high_file
+
+# Scenario 10: high to low, both files share but not with each other
+ann "high to low, both files share but not with each other"
+create_files
+if _supports_arbitrary_fileset_reflink; then
+       dummy_share $low_file 1
+       dummy_share $high_file 2
+fi
+test_files $high_file $low_file
+
+# Scenario 11: low to high, both files share mutually
+ann "low to high, both files share mutually"
+create_files
+mutual_dummy_share $low_file $high_file
+test_files $low_file $high_file
+
+# Scenario 12: high to low, both files share mutually
+ann "high to low, both files share mutually"
+create_files
+mutual_dummy_share $low_file $high_file
+test_files $high_file $low_file
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/544.out b/tests/generic/544.out
new file mode 100644 (file)
index 0000000..68392f2
--- /dev/null
@@ -0,0 +1,62 @@
+QA output created by 544
+Format and mount
+1: low to high, neither share
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+de1d43fbed633326daed6f71912e09e1  SCRATCH_MNT/test-544/high
+2: high to low, neither share
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+3: low to high, only source shares
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+de1d43fbed633326daed6f71912e09e1  SCRATCH_MNT/test-544/high
+4: high to low, only source shares
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+5: low to high, only dest shares
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+de1d43fbed633326daed6f71912e09e1  SCRATCH_MNT/test-544/high
+6: high to low, only dest shares
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+7: low to high, both files share with each other
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/high
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/high
+8: high to low, both files share with each other
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/high
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/low
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/high
+9: low to high, both files share but not with each other
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+de1d43fbed633326daed6f71912e09e1  SCRATCH_MNT/test-544/high
+10: high to low, both files share but not with each other
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+11: low to high, both files share mutually
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+de1d43fbed633326daed6f71912e09e1  SCRATCH_MNT/test-544/high
+12: high to low, both files share mutually
+07d9f5b0e07f22bff26e39f929cfc460  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
+0d2ce48b6a4527783bd30ce21f09fec0  SCRATCH_MNT/test-544/low
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-544/high
index 9f4845c6c3b65bc1ead535d44e15ed87f137f7bf..40deb4d044fc869a1b5c775e9a72b112bae2bb62 100644 (file)
 537 auto quick trim
 538 auto quick aio
 539 auto quick punch seek
+540 auto quick clone
+541 auto quick clone
+542 auto quick clone
+543 auto quick clone
+544 auto quick clone