]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/deadman/deadman_zio.ksh
Extend deadman logic
[mirror_zfs.git] / tests / zfs-tests / tests / functional / deadman / deadman_zio.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
25 # Use is subject to license terms.
26 #
27
28 # DESCRIPTION:
29 # Verify zio deadman detects a hung zio
30 #
31 # STRATEGY:
32 # 1. Reduce the zfs_deadman_ziotime_ms to 5s.
33 # 2. Reduce the zfs_deadman_checktime_ms to 1s.
34 # 3. Inject a 10s zio delay to force long IOs.
35 # 4. Read an uncached file in the background.
36 # 5. Verify a "deadman" event is posted.
37 # 6. Inject a 100ms zio delay which is under the 5s allowed.
38 # 7. Read an uncached file in the background.
39 # 8. Verify a "deadman" event is not posted.
40 #
41
42 . $STF_SUITE/include/libtest.shlib
43 . $STF_SUITE/tests/functional/deadman/deadman.cfg
44
45 verify_runnable "both"
46
47 function cleanup
48 {
49 log_must zinject -c all
50 default_cleanup_noexit
51
52 log_must set_tunable64 zfs_deadman_ziotime_ms $ZIOTIME_DEFAULT
53 log_must set_tunable64 zfs_deadman_checktime_ms $CHECKTIME_DEFAULT
54 log_must set_tunable64 zfs_deadman_failmode $FAILMODE_DEFAULT
55 }
56
57 log_assert "Verify zio deadman detects a hung zio"
58 log_onexit cleanup
59
60 # 1. Reduce the zfs_deadman_ziotime_ms to 5s.
61 log_must set_tunable64 zfs_deadman_ziotime_ms 5000
62 # 2. Reduce the zfs_deadman_checktime_ms to 1s.
63 log_must set_tunable64 zfs_deadman_checktime_ms 1000
64 log_must set_tunable64 zfs_deadman_failmode "wait"
65
66 # Create a new pool in order to use the updated deadman settings.
67 default_setup_noexit $DISK1
68
69 # Write a file and export/import the pool to clear the ARC.
70 mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
71 log_must file_write -b 1048576 -c 8 -o create -d 0 -f $mntpnt/file1
72 log_must file_write -b 1048576 -c 8 -o create -d 0 -f $mntpnt/file2
73 log_must zpool export $TESTPOOL
74 log_must zpool import $TESTPOOL
75 log_must stat -t /$mntpnt/file1
76 log_must stat -t /$mntpnt/file2
77
78 # 3. Inject a 10s zio delay to force long IOs and serialize them..
79 log_must zpool events -c
80 log_must zinject -d $DISK1 -D10000:1 $TESTPOOL
81
82 # 4. Read an uncached file in the background, it's expected to hang.
83 log_must eval "dd if=/$mntpnt/file1 of=/dev/null bs=1048576 &"
84 sleep 10
85 log_must zinject -c all
86 log_must zpool sync
87 wait
88
89 # 5. Verify a "deadman" event is posted. The first appears after 5
90 # seconds, and another each second thereafter until the delay is cleared.
91 events=$(zpool events | grep -c ereport.fs.zfs.deadman)
92 if [ "$events" -lt 1 ]; then
93 log_fail "Expect >=1 deadman events, $events found"
94 fi
95
96 # 6. Inject a 100ms zio delay which is under the 5s allowed, allow them
97 # to run concurrently so they don't get starved in the queue.
98 log_must zpool events -c
99 log_must zinject -d $DISK1 -D100:10 $TESTPOOL
100
101 # 7. Read an uncached file in the background.
102 log_must eval "dd if=/$mntpnt/file2 of=/dev/null bs=1048576 &"
103 sleep 10
104 log_must zinject -c all
105 wait
106
107 # 8. Verify a "deadman" event is not posted.
108 events=$(zpool events | grep -c ereport.fs.zfs.deadman)
109 if [ "$events" -ne 0 ]; then
110 log_fail "Expect 0 deadman events, $events found"
111 fi
112
113 log_pass "Verify zio deadman detected a hung zio and $events deadman events"