generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 194
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 194
6 #
7 # Ensuring that copy on write in direct-io mode works when the CoW
8 # range originally covers multiple extents, some delalloc, some not.
9 #   - Create a file.
10 #   - Reflink the odd blocks of the first file into the second file.
11 #   - Buffered write the even blocks of the second file.
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.
14 #
15 . ./common/preamble
16 _begin_fstest auto quick clone
17
18 # Override the default cleanup function.
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.* $testdir
23 }
24
25 # Import common functions.
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _require_scratch_reflink
31 _require_scratch_delalloc
32 _require_xfs_io_command "falloc"
33 _require_odirect
34
35 echo "Format and mount"
36 _scratch_mkfs > $seqres.full 2>&1
37 _scratch_mount >> $seqres.full 2>&1
38
39 testdir=$SCRATCH_MNT/test-$seq
40 mkdir $testdir
41
42 echo "Create the original files"
43 blksz=65536
44 nr=64
45 filesize=$((blksz * nr))
46 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
47 _scratch_cycle_mount
48
49 echo "Compare files"
50 md5sum $testdir/file1 | _filter_scratch
51 md5sum $testdir/file3 | _filter_scratch
52 md5sum $testdir/file3.chk | _filter_scratch
53
54 echo "directio CoW across the transition"
55 cowoff=$((filesize / 4))
56 cowsz=$((filesize / 2))
57 _weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full
58 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
59 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
60 _scratch_cycle_mount
61
62 echo "Compare files"
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file3 | _filter_scratch
65 md5sum $testdir/file3.chk | _filter_scratch
66
67 # success, all done
68 status=0
69 exit