3729aa5b2f524d04511b113163dbab129cc89f3d
[xfstests-dev.git] / tests / generic / 388
1 #! /bin/bash
2 # FS QA Test No. 388
3 #
4 # Test XFS log recovery ordering on v5 superblock filesystems. XFS had a problem
5 # where it would incorrectly replay older modifications from the log over more
6 # recent versions of metadata due to failure to update metadata LSNs during log
7 # recovery. This could result in false positive reports of corruption during log
8 # recovery and permanent mount failure.
9 #
10 # To test this situation, run frequent shutdowns immediately after log recovery.
11 # Ensure that log recovery does not recover stale modifications and cause
12 # spurious corruption reports and/or mount failures.
13 #
14 #-----------------------------------------------------------------------
15 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
16 #
17 # This program is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License as
19 # published by the Free Software Foundation.
20 #
21 # This program is distributed in the hope that it would be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write the Free Software Foundation,
28 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29 #-----------------------------------------------------------------------
30 #
31
32 seq=`basename $0`
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43         cd /
44         rm -f $tmp.*
45         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
46         _scratch_unmount > /dev/null 2>&1
47 }
48
49 # get standard environment, filters and checks
50 . ./common/rc
51
52 # Modify as appropriate.
53 _supported_fs generic
54 _supported_os Linux
55
56 _require_scratch
57 _require_scratch_shutdown
58 _require_command "$KILLALL_PROG" "killall"
59
60 rm -f $seqres.full
61
62 echo "Silence is golden."
63
64 _scratch_mkfs >> $seqres.full 2>&1
65 _scratch_mount || _fail "mount failed"
66
67 for i in $(seq 1 50); do
68         ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p 4 >> $seqres.full &) \
69                 > /dev/null 2>&1
70
71         # purposely include 0 second sleeps to test shutdown immediately after
72         # recovery
73         sleep $((RANDOM % 3))
74         ./src/godown $SCRATCH_MNT
75
76         ps -e | grep fsstress > /dev/null 2>&1
77         while [ $? -eq 0 ]; do
78                 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
79                 wait > /dev/null 2>&1
80                 ps -e | grep fsstress > /dev/null 2>&1
81         done
82
83         # quit if mount fails so we don't shutdown the host fs
84         _scratch_cycle_mount || _fail "cycle mount failed"
85 done
86
87 # success, all done
88 status=0
89 exit