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 delalloc, some not.
10 # - Reflink the odd blocks of the first file into the second file.
11 # - Buffered write the even blocks of the second file.
12 # - CoW across the halfway mark, starting with the unwritten extent.
13 # - Check that the files are now different where we say they're different.
16 _begin_fstest auto quick clone
18 # Override the default cleanup function.
22 rm -rf $tmp.* $testdir
25 # Import common functions.
29 # real QA test starts here
30 _require_scratch_reflink
31 _require_xfs_io_command "falloc"
33 echo "Format and mount"
34 _scratch_mkfs > $seqres.full 2>&1
35 _scratch_mount >> $seqres.full 2>&1
37 testdir=$SCRATCH_MNT/test-$seq
40 echo "Create the original files"
43 filesize=$((blksz * nr))
44 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
48 md5sum $testdir/file1 | _filter_scratch
49 md5sum $testdir/file3 | _filter_scratch
50 md5sum $testdir/file3.chk | _filter_scratch
52 echo "CoW across the transition"
53 cowoff=$((filesize / 4))
54 cowsz=$((filesize / 2))
55 _weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full
56 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
57 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
61 md5sum $testdir/file1 | _filter_scratch
62 md5sum $testdir/file3 | _filter_scratch
63 md5sum $testdir/file3.chk | _filter_scratch