generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 475
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 475
6 #
7 # Test log recovery with repeated (simulated) disk failures.  We kick
8 # off fsstress on the scratch fs, then switch out the underlying device
9 # with dm-error to see what happens when the disk goes down.  Having
10 # taken down the fs in this manner, remount it and repeat.  This test
11 # is a Good Enough (tm) simulation of our internal multipath failure
12 # testing efforts.
13 #
14 . ./common/preamble
15 _begin_fstest shutdown auto log metadata eio recoveryloop smoketest
16
17 # Override the default cleanup function.
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
23         _dmerror_unmount
24         _dmerror_cleanup
25 }
26
27 # Import common functions.
28 . ./common/dmerror
29
30 # Modify as appropriate.
31 _supported_fs generic
32
33 _require_scratch
34 _require_dm_target error
35 _require_command "$KILLALL_PROG" "killall"
36
37 echo "Silence is golden."
38
39 _scratch_mkfs >> $seqres.full 2>&1
40 _require_metadata_journaling $SCRATCH_DEV
41 _dmerror_init
42 _dmerror_mount
43
44 while _soak_loop_running $((50 * TIME_FACTOR)); do
45         ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p $((LOAD_FACTOR * 4)) >> $seqres.full &) \
46                 > /dev/null 2>&1
47
48         # purposely include 0 second sleeps to test shutdown immediately after
49         # recovery
50         sleep $((RANDOM % 3))
51
52         # This test aims to simulate sudden disk failure, which means that we
53         # do not want to quiesce the filesystem or otherwise give it a chance
54         # to flush its logs.  Therefore we want to call dmsetup with the
55         # --nolockfs parameter; to make this happen we must call the load
56         # error table helper *without* 'lockfs'.
57         _dmerror_load_error_table
58
59         ps -e | grep fsstress > /dev/null 2>&1
60         while [ $? -eq 0 ]; do
61                 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
62                 wait > /dev/null 2>&1
63                 ps -e | grep fsstress > /dev/null 2>&1
64         done
65
66         # Mount again to replay log after loading working table, so we have a
67         # consistent XFS after test.
68         _dmerror_unmount || _fail "unmount failed"
69         _dmerror_load_working_table
70         _dmerror_mount || _fail "mount failed"
71 done
72
73 # success, all done
74 status=0
75 exit