lib/: spdx license conversion
[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         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/dmlogwrites
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37
38 # Modify as appropriate.
39 _supported_fs generic
40 _supported_os Linux
41
42 _require_command "$KILLALL_PROG" killall
43 # Use $SCRATCH_DEV as replay device
44 _require_scratch
45 # and we need extra device as log device
46 _require_log_writes
47
48
49 nr_cpus=$("$here/src/feature" -o)
50 # cap nr_cpus to 8 to avoid spending too much time on hosts with many cpus
51 if [ $nr_cpus -gt 8 ]; then
52         nr_cpus=8
53 fi
54 fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
55                 $FSSTRESS_AVOID)
56
57 _test_unmount
58 _log_writes_init
59 _log_writes_mkfs >> $seqres.full 2>&1
60 _log_writes_mark mkfs
61
62 _log_writes_mount
63 run_check $FSSTRESS_PROG $fsstress_args > /dev/null 2>&1
64 _log_writes_unmount
65
66 _log_writes_remove
67 prev=$(_log_writes_mark_to_entry_number mkfs)
68 [ -z "$prev" ] && _fail "failed to locate entry mark 'mkfs'"
69 cur=$(_log_writes_find_next_fua $prev)
70 [ -z "$cur" ] && _fail "failed to locate next FUA write"
71
72 while [ ! -z "$cur" ]; do
73         _log_writes_replay_log_range $cur >> $seqres.full
74
75         # Here we need extra mount to replay the log, mainly for journal based
76         # fs, as their fsck will report dirty log as error.
77         # We don't care to preserve any data on $SCRATCH_DEV, as we can replay
78         # back to the point we need, and in fact sometimes creating/deleting
79         # snapshots repeatedly can be slower than replaying the log.
80         _scratch_mount
81         _scratch_unmount
82         _check_scratch_fs
83
84         prev=$cur
85         cur=$(_log_writes_find_next_fua $(($cur + 1)))
86         [ -z "$cur" ] && break
87 done
88
89 echo "Silence is golden"
90
91 # success, all done
92 status=0
93 exit