2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensuring that copy on write in buffered mode works when the CoW
8 # range originally covers multiple extents, some holes, some not.
9 # - Create a file and truncate a second file.
10 # - Reflink the odd blocks of the first file into the second file.
11 # - CoW across the halfway mark, starting with the unwritten extent.
12 # - Check that the files are now different where we say they're different.
15 _begin_fstest auto quick clone
17 # Override the default cleanup function.
21 rm -rf $tmp.* $testdir
24 # Import common functions.
28 # real QA test starts here
29 _require_scratch_reflink
30 _require_xfs_io_command "falloc"
32 echo "Format and mount"
33 _scratch_mkfs > $seqres.full 2>&1
34 _scratch_mount >> $seqres.full 2>&1
36 testdir=$SCRATCH_MNT/test-$seq
39 echo "Create the original files"
42 filesize=$((blksz * nr))
43 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
47 md5sum $testdir/file1 | _filter_scratch
48 md5sum $testdir/file3 | _filter_scratch
49 md5sum $testdir/file3.chk | _filter_scratch
51 echo "CoW across the transition"
52 cowoff=$((filesize / 4))
53 cowsz=$((filesize / 2))
54 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
55 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
59 md5sum $testdir/file1 | _filter_scratch
60 md5sum $testdir/file3 | _filter_scratch
61 md5sum $testdir/file3.chk | _filter_scratch