fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 482
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 SUSE Linux Products GmbH.  All Rights Reserved.
4 #
5 # FS QA Test 482
6 #
7 # Test filesystem consistency after each FUA operation
8 #
9 # Will do log replay and check the filesystem.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         $KILLALL_PROG -KILL -q $FSSTRESS_PROG &> /dev/null
24         _log_writes_cleanup &> /dev/null
25         _dmthin_cleanup
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/dmthin
33 . ./common/dmlogwrites
34
35 # remove previous $seqres.full before test
36 rm -f $seqres.full
37
38 # real QA test starts here
39
40 # Modify as appropriate.
41 _supported_fs generic
42 _supported_os Linux
43
44 _require_command "$KILLALL_PROG" killall
45 # Use thin device as replay device, which requires $SCRATCH_DEV
46 _require_scratch_nocheck
47 # and we need extra device as log device
48 _require_log_writes
49 _require_dm_target thin-pool
50
51
52 nr_cpus=$("$here/src/feature" -o)
53 # cap nr_cpus to 8 to avoid spending too much time on hosts with many cpus
54 if [ $nr_cpus -gt 8 ]; then
55         nr_cpus=8
56 fi
57 fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
58                 $FSSTRESS_AVOID)
59 devsize=$((1024*1024*200 / 512))        # 200m phys/virt size
60 csize=$((1024*64 / 512))                # 64k cluster size
61 lowspace=$((1024*1024 / 512))           # 1m low space threshold
62
63 # Use a thin device to provide deterministic discard behavior. Discards are used
64 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
65 _test_unmount
66 _dmthin_init $devsize $devsize $csize $lowspace
67 _log_writes_init $DMTHIN_VOL_DEV
68 _log_writes_mkfs >> $seqres.full 2>&1
69 _log_writes_mark mkfs
70
71 _log_writes_mount
72 run_check $FSSTRESS_PROG $fsstress_args > /dev/null 2>&1
73 _log_writes_unmount
74
75 _log_writes_remove
76 prev=$(_log_writes_mark_to_entry_number mkfs)
77 [ -z "$prev" ] && _fail "failed to locate entry mark 'mkfs'"
78 cur=$(_log_writes_find_next_fua $prev)
79 [ -z "$cur" ] && _fail "failed to locate next FUA write"
80
81 while [ ! -z "$cur" ]; do
82         _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full
83
84         # Here we need extra mount to replay the log, mainly for journal based
85         # fs, as their fsck will report dirty log as error.
86         # We don't care to preserve any data on the replay dev, as we can replay
87         # back to the point we need, and in fact sometimes creating/deleting
88         # snapshots repeatedly can be slower than replaying the log.
89         _dmthin_mount
90         _dmthin_check_fs
91
92         prev=$cur
93         cur=$(_log_writes_find_next_fua $(($cur + 1)))
94         [ -z "$cur" ] && break
95 done
96
97 echo "Silence is golden"
98
99 # success, all done
100 status=0
101 exit