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 _begin_fstest auto metadata replay thin
14 # Override the default cleanup function.
16 # If debugging logwrites failures using the tools/dm-logwrite-replay script,
17 # switch the cleanup function to the version that is commented out below so that
18 # failure leaves the corpse intact for post-mortem failure analysis.
22 $KILLALL_PROG -KILL -q $FSSTRESS_PROG &> /dev/null
23 _log_writes_cleanup &> /dev/null
28 # tools/dm-logwrite-replay _cleanup version
32 # $KILLALL_PROG -KILL -q $FSSTRESS_PROG &> /dev/null
33 # if [ $status -eq 0 ]; then
34 # _log_writes_cleanup &> /dev/null
37 # echo dm-thinvol-dev: $DMTHIN_VOL_DEV >> $seqres.full
42 # Import common functions.
45 . ./common/dmlogwrites
47 # real QA test starts here
49 # Modify as appropriate.
52 _require_command "$KILLALL_PROG" killall
53 # Use thin device as replay device, which requires $SCRATCH_DEV
54 _require_scratch_nocheck
55 # and we need extra device as log device
57 _require_dm_target thin-pool
59 nr_cpus=$("$here/src/feature" -o)
60 # cap nr_cpus to 8 to avoid spending too much time on hosts with many cpus
61 if [ $nr_cpus -gt 8 ]; then
64 fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
66 devsize=$((1024*1024*200 / 512)) # 200m phys/virt size
67 csize=$((1024*64 / 512)) # 64k cluster size
68 lowspace=$((1024*1024 / 512)) # 1m low space threshold
70 # Use a thin device to provide deterministic discard behavior. Discards are used
71 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
73 _dmthin_init $devsize $devsize $csize $lowspace
74 _log_writes_init $DMTHIN_VOL_DEV
75 _log_writes_mkfs >> $seqres.full 2>&1
79 run_check $FSSTRESS_PROG $fsstress_args > /dev/null 2>&1
83 prev=$(_log_writes_mark_to_entry_number mkfs)
84 [ -z "$prev" ] && _fail "failed to locate entry mark 'mkfs'"
85 cur=$(_log_writes_find_next_fua $prev)
86 [ -z "$cur" ] && _fail "failed to locate next FUA write"
88 while [ ! -z "$cur" ]; do
89 _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full
91 # Here we need extra mount to replay the log, mainly for journal based
92 # fs, as their fsck will report dirty log as error.
93 # We don't care to preserve any data on the replay dev, as we can replay
94 # back to the point we need, and in fact sometimes creating/deleting
95 # snapshots repeatedly can be slower than replaying the log.
100 cur=$(_log_writes_find_next_fua $(($cur + 1)))
101 [ -z "$cur" ] && break
104 echo "Silence is golden"