generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 240
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. 240
6 #
7 # Test AIO CoW behavior when the write temporarily fails.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick clone eio
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15     cd /
16     rm -rf $tmp.* $TEST_DIR/moo
17     _dmerror_cleanup
18 }
19
20 # Import common functions.
21 . ./common/filter
22 . ./common/reflink
23 . ./common/dmerror
24
25 # real QA test starts here
26 _supported_fs xfs
27 _require_scratch_reflink
28 _require_cp_reflink
29 _require_dm_target error
30 _require_xfs_io_command "cowextsize"
31 _require_aiodio "aiocp"
32 AIO_TEST="$here/src/aio-dio-regress/aiocp"
33
34 echo "Format and mount"
35 _scratch_mkfs > $seqres.full 2>&1
36 _dmerror_init
37 _dmerror_mount >> $seqres.full 2>&1
38
39 testdir=$SCRATCH_MNT/test-$seq
40 mkdir $testdir
41
42 blksz=65536
43 nr=640
44 bufnr=128
45 filesize=$((blksz * nr))
46 bufsize=$((blksz * bufnr))
47 filesize=$filesize
48 bufsize=$bufsize
49
50 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
51
52 echo "Create the original files"
53 $XFS_IO_PROG -c "cowextsize $((bufsize * 2))" $testdir
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
56 _dmerror_unmount
57 _dmerror_mount
58
59 echo "Compare files"
60 md5sum $testdir/file1 | _filter_scratch
61 md5sum $testdir/file2 | _filter_scratch
62
63 echo "CoW and unmount"
64 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
65 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
66 sync
67 _dmerror_load_error_table
68 $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
69 $XFS_IO_PROG -c "fdatasync" $testdir/file2
70 _dmerror_load_working_table
71 _dmerror_unmount
72 _dmerror_mount
73
74 echo "Compare files"
75 md5sum $testdir/file1 | _filter_scratch
76 md5sum $testdir/file2 | _filter_scratch
77
78 echo "Check for damage"
79 _dmerror_unmount
80 _dmerror_cleanup
81 _repair_scratch_fs >> $seqres.full
82
83 # success, all done
84 status=0
85 exit