generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 388
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 388
6 #
7 # Test XFS log recovery ordering on v5 superblock filesystems. XFS had a problem
8 # where it would incorrectly replay older modifications from the log over more
9 # recent versions of metadata due to failure to update metadata LSNs during log
10 # recovery. This could result in false positive reports of corruption during log
11 # recovery and permanent mount failure.
12 #
13 # To test this situation, run frequent shutdowns immediately after log recovery.
14 # Ensure that log recovery does not recover stale modifications and cause
15 # spurious corruption reports and/or mount failures.
16 #
17 . ./common/preamble
18 _begin_fstest shutdown auto log metadata recoveryloop
19
20 # Override the default cleanup function.
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
26         _scratch_unmount > /dev/null 2>&1
27 }
28
29 # Import common functions.
30
31 # Modify as appropriate.
32 _supported_fs generic
33
34 _require_scratch
35 _require_local_device $SCRATCH_DEV
36 _require_scratch_shutdown
37 _require_command "$KILLALL_PROG" "killall"
38
39 echo "Silence is golden."
40
41 _scratch_mkfs >> $seqres.full 2>&1
42 _require_metadata_journaling $SCRATCH_DEV
43 _scratch_mount
44
45 for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
46         ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p 4 >> $seqres.full &) \
47                 > /dev/null 2>&1
48
49         # purposely include 0 second sleeps to test shutdown immediately after
50         # recovery
51         sleep $((RANDOM % 3))
52         _scratch_shutdown
53
54         ps -e | grep fsstress > /dev/null 2>&1
55         while [ $? -eq 0 ]; do
56                 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
57                 wait > /dev/null 2>&1
58                 ps -e | grep fsstress > /dev/null 2>&1
59         done
60
61         # Toggle between rw and ro mounts for recovery. Quit if any mount
62         # attempt fails so we don't shutdown the host fs.
63         if [ $((RANDOM % 2)) -eq 0 ]; then
64                 _scratch_cycle_mount || _fail "cycle mount failed"
65         else
66                 _scratch_cycle_mount "ro" || _fail "cycle ro mount failed"
67                 _scratch_cycle_mount || _fail "cycle rw mount failed"
68         fi
69 done
70
71 # success, all done
72 status=0
73 exit