4 # Ensuring that copy on write in direct-io mode works when the CoW
5 # range originally covers multiple extents.
7 # - Reflink the odd blocks of the first file into a third file.
8 # - Reflink the even blocks of the second file into the third file.
9 # - directio CoW across the halfway mark.
10 # - Check that the files are now different where we say they're different.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
41 rm -rf $tmp.* $testdir
44 # get standard environment, filters and checks
49 # real QA test starts here
51 _require_scratch_reflink
56 echo "Format and mount"
57 _scratch_mkfs > $seqres.full 2>&1
58 _scratch_mount >> $seqres.full 2>&1
60 testdir=$SCRATCH_MNT/test-$seq
63 echo "Create the original files"
66 filesize=$((blksz * nr))
67 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
68 _pwrite_byte 0x62 0 $filesize $testdir/file2 >> $seqres.full
69 seq 0 2 $((nr-1)) | while read f; do
70 _reflink_range $testdir/file1 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full
71 _pwrite_byte 0x61 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full
73 seq 1 2 $((nr-1)) | while read f; do
74 _reflink_range $testdir/file2 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full
75 _pwrite_byte 0x62 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full
80 md5sum $testdir/file1 | _filter_scratch
81 md5sum $testdir/file2 | _filter_scratch
82 md5sum $testdir/file3 | _filter_scratch
83 md5sum $testdir/file3.chk | _filter_scratch
85 echo "directio CoW across the transition"
86 cowoff=$((filesize / 4))
87 cowsz=$((filesize / 2))
88 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
89 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
93 md5sum $testdir/file1 | _filter_scratch
94 md5sum $testdir/file2 | _filter_scratch
95 md5sum $testdir/file3 | _filter_scratch
96 md5sum $testdir/file3.chk | _filter_scratch