4 # Ensuring that copy on write in direct-io mode works when the CoW
5 # range originally covers multiple extents, some unwritten, some not.
6 # - Create a file with the following repeating sequence of blocks:
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.
15 #-----------------------------------------------------------------------
16 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #-----------------------------------------------------------------------
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
38 status=1 # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
44 rm -rf $tmp.* $testdir
47 # get standard environment, filters and checks
52 # real QA test starts here
54 _require_scratch_reflink
55 _require_xfs_io_command "falloc"
56 _require_xfs_io_command "fpunch"
62 echo "Format and mount"
63 _scratch_mkfs > $seqres.full 2>&1
64 _scratch_mount >> $seqres.full 2>&1
66 testdir=$SCRATCH_MNT/test-$seq
69 echo "Create the original files"
72 filesize=$((blksz * nr))
73 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
77 md5sum $testdir/file1 | _filter_scratch
78 md5sum $testdir/file3 | _filter_scratch
79 md5sum $testdir/file3.chk | _filter_scratch
81 echo "directio CoW across the transition"
82 cowoff=$((filesize / 4))
83 cowsz=$((filesize / 2))
84 _weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
86 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
87 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
91 md5sum $testdir/file1 | _filter_scratch
92 md5sum $testdir/file3 | _filter_scratch
93 md5sum $testdir/file3.chk | _filter_scratch