aboutsummaryrefslogtreecommitdiff
path: root/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh
blob: 7b18ebdcb85929c881f3385b6220ab5a514205e6 (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
# Use is subject to license terms.
#

# DESCRIPTION:
#	Verify spa deadman detects a hung txg
#
# STRATEGY:
#	1. Reduce the zfs_deadman_synctime_ms to 5s.
#	2. Reduce the zfs_deadman_checktime_ms to 1s.
#	3. Inject a 10s zio delay to force long IOs.
#	4. Write enough data to force a long txg sync time due to the delay.
#	5. Verify a "deadman" event is posted.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/deadman/deadman.cfg

verify_runnable "both"

function cleanup
{
	log_must zinject -c all
	default_cleanup_noexit

	log_must set_tunable64 DEADMAN_SYNCTIME_MS $SYNCTIME_DEFAULT
	log_must set_tunable64 DEADMAN_CHECKTIME_MS $CHECKTIME_DEFAULT
	log_must set_tunable64 DEADMAN_FAILMODE $FAILMODE_DEFAULT
}

log_assert "Verify spa deadman detects a hung txg"
log_onexit cleanup

log_must set_tunable64 DEADMAN_SYNCTIME_MS 5000
log_must set_tunable64 DEADMAN_CHECKTIME_MS 1000
log_must set_tunable64 DEADMAN_FAILMODE "wait"

# Create a new pool in order to use the updated deadman settings.
default_setup_noexit $DISK1
log_must zpool events -c

# Force each IO to take 10s by allow them to run concurrently.
log_must zinject -d $DISK1 -D10000:10 $TESTPOOL

mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
log_must file_write -b 1048576 -c 8 -o create -d 0 -f $mntpnt/file
sleep 10

log_must zinject -c all
sync_all_pools

# Log txg sync times for reference and the zpool event summary.
if is_freebsd; then
	log_must sysctl -n kstat.zfs.$TESTPOOL.txgs
else
	log_must cat /proc/spl/kstat/zfs/$TESTPOOL/txgs
fi
log_must zpool events

# Verify at least 4 deadman events were logged.  The first after 5 seconds,
# and another each second thereafter until the delay  is clearer.
events=$(zpool events | grep -c ereport.fs.zfs.deadman)
if [ "$events" -lt 4 ]; then
	log_fail "Expect >=5 deadman events, $events found"
fi

log_pass "Verify spa deadman detected a hung txg and $events deadman events"