fstests: use _require_symlinks on all necessary tests
[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 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
28         _dmerror_unmount
29         _dmerror_cleanup
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/dmerror
35
36 # Modify as appropriate.
37 _supported_fs generic
38 _supported_os Linux
39
40 _require_scratch
41 _require_dm_target error
42 _require_command "$KILLALL_PROG" "killall"
43
44 rm -f $seqres.full
45
46 echo "Silence is golden."
47
48 _scratch_mkfs >> $seqres.full 2>&1
49 _require_metadata_journaling $SCRATCH_DEV
50 _dmerror_init
51 _dmerror_mount
52
53 for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
54         ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p $((LOAD_FACTOR * 4)) >> $seqres.full &) \
55                 > /dev/null 2>&1
56
57         # purposely include 0 second sleeps to test shutdown immediately after
58         # recovery
59         sleep $((RANDOM % 3))
60
61         # This test aims to simulate sudden disk failure, which means that we
62         # do not want to quiesce the filesystem or otherwise give it a chance
63         # to flush its logs.  Therefore we want to call dmsetup with the
64         # --nolockfs parameter; to make this happen we must call the load
65         # error table helper *without* 'lockfs'.
66         _dmerror_load_error_table
67
68         ps -e | grep fsstress > /dev/null 2>&1
69         while [ $? -eq 0 ]; do
70                 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
71                 wait > /dev/null 2>&1
72                 ps -e | grep fsstress > /dev/null 2>&1
73         done
74
75         # Mount again to replay log after loading working table, so we have a
76         # consistent XFS after test.
77         _dmerror_unmount || _fail "unmount failed"
78         _dmerror_load_working_table
79         _dmerror_mount || _fail "mount failed"
80 done
81
82 # success, all done
83 status=0
84 exit