generic: convert tests to SPDX license tags
[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 seq=`basename $0`
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28         cd /
29         rm -f $tmp.*
30         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
31         _scratch_unmount > /dev/null 2>&1
32 }
33
34 # get standard environment, filters and checks
35 . ./common/rc
36
37 # Modify as appropriate.
38 _supported_fs generic
39 _supported_os Linux
40
41 _require_scratch
42 _require_local_device $SCRATCH_DEV
43 _require_scratch_shutdown
44 _require_command "$KILLALL_PROG" "killall"
45
46 rm -f $seqres.full
47
48 echo "Silence is golden."
49
50 _scratch_mkfs >> $seqres.full 2>&1
51 _require_metadata_journaling $SCRATCH_DEV
52 _scratch_mount
53
54 for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
55         ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p 4 >> $seqres.full &) \
56                 > /dev/null 2>&1
57
58         # purposely include 0 second sleeps to test shutdown immediately after
59         # recovery
60         sleep $((RANDOM % 3))
61         _scratch_shutdown
62
63         ps -e | grep fsstress > /dev/null 2>&1
64         while [ $? -eq 0 ]; do
65                 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
66                 wait > /dev/null 2>&1
67                 ps -e | grep fsstress > /dev/null 2>&1
68         done
69
70         # quit if mount fails so we don't shutdown the host fs
71         _scratch_cycle_mount || _fail "cycle mount failed"
72 done
73
74 # success, all done
75 status=0
76 exit