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 and fallocate a second file.
10 # - Reflink the odd blocks of the first file into the second file.
11 # - directio 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"
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_unwritten $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 "directio CoW across the transition"
53 cowoff=$((filesize / 4))
54 cowsz=$((filesize / 2))
55 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
56 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
60 md5sum $testdir/file1 | _filter_scratch
61 md5sum $testdir/file3 | _filter_scratch
62 md5sum $testdir/file3.chk | _filter_scratch