2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test filesystem consistency after each FUA operation
9 # Will do log replay and check the filesystem.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
23 $KILLALL_PROG -KILL -q $FSSTRESS_PROG &> /dev/null
24 _log_writes_cleanup &> /dev/null
29 # get standard environment, filters and checks
33 . ./common/dmlogwrites
35 # remove previous $seqres.full before test
38 # real QA test starts here
40 # Modify as appropriate.
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
49 _require_dm_target thin-pool
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
57 fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
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
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.
66 _dmthin_init $devsize $devsize $csize $lowspace
67 _log_writes_init $DMTHIN_VOL_DEV
68 _log_writes_mkfs >> $seqres.full 2>&1
72 run_check $FSSTRESS_PROG $fsstress_args > /dev/null 2>&1
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"
81 while [ ! -z "$cur" ]; do
82 _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full
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.
93 cur=$(_log_writes_find_next_fua $(($cur + 1)))
94 [ -z "$cur" ] && break
97 echo "Silence is golden"