4 # Ensuring that copy on write in direct-io mode works when the CoW
5 # range originally covers multiple extents, some unwritten, some not.
7 # - Reflink the odd blocks of the first file into the second file.
8 # - directio CoW across the halfway mark, starting with the unwritten extent.
9 # - Check that the files are now different where we say they're different.
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
29 seqres="$RESULT_DIR/$seq"
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
40 rm -rf "$tmp".* "$TESTDIR"
43 # get standard environment, filters and checks
48 # real QA test starts here
50 _require_scratch_reflink
51 _require_xfs_io_command "falloc"
55 echo "Format and mount"
56 _scratch_mkfs > "$seqres.full" 2>&1
57 _scratch_mount >> "$seqres.full" 2>&1
59 TESTDIR="$SCRATCH_MNT/test-$seq"
63 echo "Create the original files"
66 _pwrite_byte 0x61 0 $((BLKSZ * NR)) "$TESTDIR/file1" >> "$seqres.full"
67 _pwrite_byte 0x62 0 $((BLKSZ * NR)) "$TESTDIR/file3" >> "$seqres.full"
68 _pwrite_byte 0x62 0 $((BLKSZ * NR)) "$TESTDIR/file3.chk" >> "$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"
76 md5sum "$TESTDIR/file1" | _filter_scratch
77 md5sum "$TESTDIR/file3" | _filter_scratch
78 md5sum "$TESTDIR/file3.chk" | _filter_scratch
80 echo "directio CoW across the transition"
81 "$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((BLKSZ * NR / 2)) $((BLKSZ * NR / 4)) $((BLKSZ * NR / 2))" "$TESTDIR/file3" >> "$seqres.full"
82 _pwrite_byte 0x63 $((BLKSZ * NR / 4)) $((BLKSZ * NR / 2)) "$TESTDIR/file3.chk" >> "$seqres.full"
86 md5sum "$TESTDIR/file1" | _filter_scratch
87 md5sum "$TESTDIR/file3" | _filter_scratch
88 md5sum "$TESTDIR/file3.chk" | _filter_scratch
90 echo "Check for damage"