summaryrefslogtreecommitdiff
path: root/tests/xfs/141
blob: d9b2474daa8085b7f4a3af0fc718649b7ef48632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
#
# FS QA Test No. 141
#
# Use the XFS log record CRC error injection mechanism to test torn writes to
# the log. The error injection mechanism writes an invalid CRC and shuts down
# the filesystem. The test verifies that a subsequent remount recovers the log
# and that the filesystem is consistent.
#
# Note that this test requires a DEBUG mode kernel.
#
. ./common/preamble
_begin_fstest auto log metadata

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -f $tmp.*
	$KILLALL_PROG -9 fsstress > /dev/null 2>&1
	wait > /dev/null 2>&1
}

# Import common functions.
. ./common/inject

# real QA test starts here

# Modify as appropriate.
_supported_fs xfs
_require_xfs_io_error_injection "log_bad_crc"
_require_scratch
_require_command "$KILLALL_PROG" killall

echo "Silence is golden."

_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
_scratch_mount

sdev=$(_short_dev $SCRATCH_DEV)

nr_times=$((TIME_FACTOR * 5))
while [ $nr_times -gt 0 ]; do
	# Enable error injection. Use a random bad crc factor up to 100
	# (increase this value to run fsstress longer).
	factor=$((RANDOM % 100 + 1))
	echo iteration $i log_badcrc_factor: $factor >> $seqres.full 2>&1
	_scratch_inject_error "log_bad_crc" "$factor"

	# Run fsstress until the filesystem shuts down. It will shut down
	# automatically when error injection triggers.
	$FSSTRESS_PROG -d $SCRATCH_MNT -p 4 -n 999999 >> $seqres.full 2>&1

	# Verify that we can remount the fs. Log recovery should handle the torn
	# write.
	_scratch_unmount
	_scratch_mount
	nr_times=$((nr_times - 1))
done

# success, all done
status=0
exit