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 seqres=$RESULT_DIR/$seq
20 echo "QA output created by $seq"
24 status=1 # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
30 rm -rf $tmp.* $testdir
33 # get standard environment, filters and checks
38 # real QA test starts here
40 _require_scratch_reflink
41 _require_xfs_io_command "falloc"
42 _require_xfs_io_command "fpunch"
48 echo "Format and mount"
49 _scratch_mkfs > $seqres.full 2>&1
50 _scratch_mount >> $seqres.full 2>&1
52 testdir=$SCRATCH_MNT/test-$seq
55 echo "Create the original files"
58 filesize=$((blksz * nr))
59 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file3 | _filter_scratch
65 md5sum $testdir/file3.chk | _filter_scratch
67 echo "directio CoW across the transition"
68 cowoff=$((filesize / 4))
69 cowsz=$((filesize / 2))
70 _weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
72 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
73 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
77 md5sum $testdir/file1 | _filter_scratch
78 md5sum $testdir/file3 | _filter_scratch
79 md5sum $testdir/file3.chk | _filter_scratch