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 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 # - directio 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 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
27 rm -rf $tmp.* $testdir
30 # get standard environment, filters and checks
35 # real QA test starts here
37 _require_scratch_reflink
38 _require_xfs_io_command "falloc"
43 echo "Format and mount"
44 _scratch_mkfs > $seqres.full 2>&1
45 _scratch_mount >> $seqres.full 2>&1
47 testdir=$SCRATCH_MNT/test-$seq
50 echo "Create the original files"
53 filesize=$((blksz * nr))
54 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
58 md5sum $testdir/file1 | _filter_scratch
59 md5sum $testdir/file3 | _filter_scratch
60 md5sum $testdir/file3.chk | _filter_scratch
62 echo "directio CoW across the transition"
63 cowoff=$((filesize / 4))
64 cowsz=$((filesize / 2))
65 _weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full
66 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
67 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
71 md5sum $testdir/file1 | _filter_scratch
72 md5sum $testdir/file3 | _filter_scratch
73 md5sum $testdir/file3.chk | _filter_scratch