common/rc: add scratch shutdown support for overlayfs
[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_local_device $SCRATCH_DEV
58 _require_scratch_shutdown
59 _require_command "$KILLALL_PROG" "killall"
60
61 rm -f $seqres.full
62
63 echo "Silence is golden."
64
65 _scratch_mkfs >> $seqres.full 2>&1
66 _require_metadata_journaling $SCRATCH_DEV
67 _scratch_mount || _fail "mount failed"
68
69 for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
70         ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p 4 >> $seqres.full &) \
71                 > /dev/null 2>&1
72
73         # purposely include 0 second sleeps to test shutdown immediately after
74         # recovery
75         sleep $((RANDOM % 3))
76         _scratch_shutdown
77
78         ps -e | grep fsstress > /dev/null 2>&1
79         while [ $? -eq 0 ]; do
80                 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
81                 wait > /dev/null 2>&1
82                 ps -e | grep fsstress > /dev/null 2>&1
83         done
84
85         # quit if mount fails so we don't shutdown the host fs
86         _scratch_cycle_mount || _fail "cycle mount failed"
87 done
88
89 # success, all done
90 status=0
91 exit