]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / fault / zpool_status_-s.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) 2018 by Lawrence Livermore National Security, LLC.
25 #
26
27 # DESCRIPTION:
28 #       Verify zpool status -s (slow IOs) works
29 #
30 # STRATEGY:
31 #       1. Create a file
32 #       2. Inject slow IOs into the pool
33 #       3. Verify we can see the slow IOs with "zpool status -s".
34 #       4. Verify we can see delay events.
35 #
36
37 . $STF_SUITE/include/libtest.shlib
38 . $STF_SUITE/include/zpool_script.shlib
39
40 DISK=${DISKS%% *}
41
42 verify_runnable "both"
43
44 default_mirror_setup_noexit $DISKS
45
46 function cleanup
47 {
48         log_must zinject -c all
49         log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO
50         log_must set_tunable64 SLOW_IO_EVENTS_PER_SECOND $OLD_SLOW_IO_EVENTS
51         default_cleanup_noexit
52 }
53
54 log_onexit cleanup
55
56 log_must zpool events -c
57
58 # Mark any IOs greater than 10ms as slow IOs
59 OLD_SLOW_IO=$(get_tunable ZIO_SLOW_IO_MS)
60 OLD_SLOW_IO_EVENTS=$(get_tunable SLOW_IO_EVENTS_PER_SECOND)
61 log_must set_tunable64 ZIO_SLOW_IO_MS 10
62 log_must set_tunable64 SLOW_IO_EVENTS_PER_SECOND 1000
63
64 # Create 20ms IOs
65 log_must zinject -d $DISK -D20:100 $TESTPOOL
66 log_must mkfile 1048576 /$TESTPOOL/testfile
67 log_must zpool sync $TESTPOOL
68
69 log_must zinject -c all
70 SLOW_IOS=$(zpool status -sp | grep "$DISK" | awk '{print $6}')
71 DELAY_EVENTS=$(zpool events | grep delay | wc -l)
72
73 if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then
74         log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events"
75 else
76         log_fail "Only saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events"
77 fi