2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensuring that reflinking works when the source range covers multiple
8 # extents, some unwritten, some not:
10 # - Create a file with the following repeating sequence of blocks:
16 # - reflink across the halfway mark, starting with the unwritten extent.
17 # - Check that the files are now different where we say they're different.
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
25 status=1 # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
34 # get standard environment, filters and checks
39 # real QA test starts here
41 _require_scratch_reflink
42 _require_xfs_io_command "falloc"
46 echo "Format and mount"
47 _scratch_mkfs > $seqres.full 2>&1
48 _scratch_mount >> $seqres.full 2>&1
50 testdir=$SCRATCH_MNT/test-$seq
53 echo "Create the original files"
56 filesize=$((blksz * nr))
57 _pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2 >> $seqres.full
58 _pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2.chk >> $seqres.full
59 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file2 | _filter_scratch
65 md5sum $testdir/file2.chk | _filter_scratch
66 md5sum $testdir/file3 | _filter_scratch
67 md5sum $testdir/file3.chk | _filter_scratch
69 echo "reflink across the transition"
70 roff=$((filesize / 4))
72 _weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
74 # now reflink the rainbow
75 echo "before reflink" >> $seqres.full
76 $FILEFRAG_PROG -v $testdir/file2 >> $seqres.full 2>&1
77 $FILEFRAG_PROG -v $testdir/file3 >> $seqres.full 2>&1
78 $XFS_IO_PROG -f -c "reflink $testdir/file3 $roff $roff $rsz" $testdir/file2 >> $seqres.full
79 cp $testdir/file3.chk $testdir/file2.chk
80 _pwrite_byte 0x64 0 $roff $testdir/file2.chk >> $seqres.full
81 _pwrite_byte 0x64 $((roff + rsz)) $((filesize - (roff + rsz) )) $testdir/file2.chk >> $seqres.full
85 echo "after reflink" >> $seqres.full
86 $FILEFRAG_PROG -v $testdir/file2 >> $seqres.full 2>&1
87 $FILEFRAG_PROG -v $testdir/file3 >> $seqres.full 2>&1
88 md5sum $testdir/file1 | _filter_scratch
89 md5sum $testdir/file2 | _filter_scratch
90 md5sum $testdir/file2.chk | _filter_scratch
91 md5sum $testdir/file3 | _filter_scratch
92 md5sum $testdir/file3.chk | _filter_scratch