generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 515
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 515
6 #
7 # Ensure that reflinking into a file well beyond EOF zeroes everything between
8 # the old EOF and the start of the newly linked chunk.  This is an adaptation
9 # of a reproducer script that Eric Sandeen formulated from a stale data
10 # exposure bug uncovered by shared/010.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick clone
14
15 # Import common functions.
16 . ./common/filter
17 . ./common/reflink
18
19 # real QA test starts here
20 _supported_fs generic
21 _require_scratch_reflink
22 _require_xfs_io_command "falloc"
23
24 # Fill disk with a well known pattern so that stale data exposure becomes much
25 # more obvious.
26 $XFS_IO_PROG -c "pwrite -S 0x58 -b 1m 0 300m" $SCRATCH_DEV >> $seqres.full
27 _scratch_mkfs_sized $((300 * 1048576)) >>$seqres.full 2>&1
28 _scratch_mount
29
30 DONOR1=$SCRATCH_MNT/a
31 TARGET=$SCRATCH_MNT/b
32 blksz=65536
33
34 $XFS_IO_PROG -f -c "pwrite -S 0x72 0 $blksz" $DONOR1 >> $seqres.full
35
36 $XFS_IO_PROG -f \
37         -c "falloc -k $((blksz*2)) $blksz"        \
38         -c "pwrite -S 0x57 $((blksz*16)) 8192" \
39         -c "fdatasync" \
40         -c 'stat' \
41         -c "reflink $DONOR1 0 $((blksz*17)) $blksz" \
42                 $TARGET >> $seqres.full
43
44 od -tx1 -Ad -c $TARGET >> $seqres.full
45 md5sum $DONOR1 | _filter_scratch
46 md5sum $TARGET | _filter_scratch
47
48 _scratch_cycle_mount
49
50 od -tx1 -Ad -c $TARGET >> $seqres.full
51 md5sum $DONOR1 | _filter_scratch
52 md5sum $TARGET | _filter_scratch
53
54 status=0
55 exit