generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 295
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. 295
6 #
7 # Ensuring that copy on write in directio mode to the source file when the
8 # CoW range covers delalloc blocks and regular shared blocks.
9 #   - Create two files.
10 #   - Truncate the first file.
11 #   - Write the odd blocks of the first file.
12 #   - Reflink the odd blocks of the first file into the second file.
13 #   - Write the even blocks of the first file.
14 #   - DIO CoW the first file across the halfway mark, starting with the
15 #     regular extent.
16 #   - Check that the files are now different where we say they're different.
17 #
18 . ./common/preamble
19 _begin_fstest auto quick clone
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/reflink
24
25 # real QA test starts here
26 _require_scratch_reflink
27 _require_xfs_io_command "falloc"
28 _require_odirect
29
30 echo "Format and mount"
31 _scratch_mkfs > $seqres.full 2>&1
32 _scratch_mount >> $seqres.full 2>&1
33
34 testdir=$SCRATCH_MNT/test-$seq
35 mkdir $testdir
36
37 echo "Create the original files"
38 blksz=65536
39 nr=64
40 filesize=$((blksz * nr))
41 _sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
42 _scratch_cycle_mount
43
44 echo "Compare files"
45 md5sum $testdir/file1 | _filter_scratch
46 md5sum $testdir/file3 | _filter_scratch
47 md5sum $testdir/file1.chk | _filter_scratch
48
49 echo "CoW across the transition"
50 cowoff=$((filesize / 4))
51 cowsz=$((filesize / 2))
52 _sweave_reflink_holes_delalloc $blksz $nr $testdir/file1 >> $seqres.full
53 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
54 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
55 _scratch_cycle_mount
56
57 echo "Compare files"
58 md5sum $testdir/file1 | _filter_scratch
59 md5sum $testdir/file3 | _filter_scratch
60 md5sum $testdir/file1.chk | _filter_scratch
61
62 # success, all done
63 status=0
64 exit