4 # Ensuring that copy on write in buffered mode works when the CoW
5 # range originally covers multiple extents, some delalloc, some not.
7 # - Reflink the odd blocks of the first file into the second file.
8 # - Buffered write the even blocks of the second file.
9 # - CoW across the halfway mark, starting with the unwritten extent.
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
52 _require_xfs_io_command "falloc"
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 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
71 md5sum $testdir/file1 | _filter_scratch
72 md5sum $testdir/file3 | _filter_scratch
73 md5sum $testdir/file3.chk | _filter_scratch
75 echo "CoW across the transition"
76 cowoff=$((filesize / 4))
77 cowsz=$((filesize / 2))
78 _weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full
79 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
80 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
84 md5sum $testdir/file1 | _filter_scratch
85 md5sum $testdir/file3 | _filter_scratch
86 md5sum $testdir/file3.chk | _filter_scratch