generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 287
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 287
6 #
7 # Ensuring that copy on write in directio mode to the source file when the
8 # CoW range covers regular unshared and regular shared blocks.
9 #   - Create two files.
10 #   - Reflink the odd blocks of the first file into the second file.
11 #   - dio CoW the first file across the halfway mark, starting with the
12 #     regular 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 # Import common functions.
19 . ./common/filter
20 . ./common/reflink
21
22 # real QA test starts here
23 _require_scratch_reflink
24 _require_xfs_io_command "falloc"
25 _require_odirect
26
27 echo "Format and mount"
28 _scratch_mkfs > $seqres.full 2>&1
29 _scratch_mount >> $seqres.full 2>&1
30
31 testdir=$SCRATCH_MNT/test-$seq
32 mkdir $testdir
33
34 echo "Create the original files"
35 blksz=65536
36 nr=64
37 filesize=$((blksz * nr))
38 _sweave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
39 _scratch_cycle_mount
40
41 echo "Compare files"
42 md5sum $testdir/file1 | _filter_scratch
43 md5sum $testdir/file3 | _filter_scratch
44 md5sum $testdir/file1.chk | _filter_scratch
45
46 echo "CoW across the transition"
47 cowoff=$((filesize / 4))
48 cowsz=$((filesize / 2))
49 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
50 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
51 _scratch_cycle_mount
52
53 echo "Compare files"
54 md5sum $testdir/file1 | _filter_scratch
55 md5sum $testdir/file3 | _filter_scratch
56 md5sum $testdir/file1.chk | _filter_scratch
57
58 # success, all done
59 status=0
60 exit