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 direct-io mode works when the CoW
8 # range originally covers multiple extents, some unwritten, some not.
9 # - Create a file with the following repeating sequence of blocks:
15 # - directio CoW across the halfway mark, starting with the unwritten extent.
16 # - Check that the files are now different where we say they're different.
19 _begin_fstest auto quick clone punch
21 # Override the default cleanup function.
25 rm -rf $tmp.* $testdir
28 # Import common functions.
32 # real QA test starts here
33 _require_scratch_reflink
34 _require_xfs_io_command "falloc"
35 _require_xfs_io_command "fpunch"
39 echo "Format and mount"
40 _scratch_mkfs > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
43 testdir=$SCRATCH_MNT/test-$seq
46 echo "Create the original files"
49 filesize=$((blksz * nr))
50 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
54 md5sum $testdir/file1 | _filter_scratch
55 md5sum $testdir/file3 | _filter_scratch
56 md5sum $testdir/file3.chk | _filter_scratch
58 echo "directio CoW across the transition"
59 cowoff=$((filesize / 4))
60 cowsz=$((filesize / 2))
61 _weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
63 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
64 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
68 md5sum $testdir/file1 | _filter_scratch
69 md5sum $testdir/file3 | _filter_scratch
70 md5sum $testdir/file3.chk | _filter_scratch