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# Copyright 2019 Joyent, Inc.
26#
27
28# DESCRIPTION:
29#	Verify zpool status -s (slow IOs) works
30#
31# STRATEGY:
32#	1. Create a file
33#	2. Inject slow IOs into the pool
34#	3. Verify we can see the slow IOs with "zpool status -s".
35#	4. Verify we can see delay events.
36#
37
38. $STF_SUITE/include/libtest.shlib
39. $STF_SUITE/include/zpool_script.shlib
40
41# Zol/illumos Porting Note: The commands commented out below are due to the ZoL
42# "event" support which has not yet been ported to illumos.
43
44DISK=${DISKS%% *}
45
46verify_runnable "both"
47
48log_must zpool create $TESTPOOL mirror ${DISKS}
49
50function cleanup
51{
52	log_must zinject -c all
53	log_must set_tunable32 zio_slow_io_ms $OLD_SLOW_IO
54#	log_must set_tunable64 zfs_slow_io_events_per_second $OLD_SLOW_IO_EVENTS
55	log_must destroy_pool $TESTPOOL
56}
57
58log_onexit cleanup
59
60# log_must zpool events -c
61
62# Mark any IOs greater than 10ms as slow IOs
63OLD_SLOW_IO=$(get_tunable zio_slow_io_ms)
64# OLD_SLOW_IO_EVENTS=$(get_tunable zfs_slow_io_events_per_second)
65log_must set_tunable32 zio_slow_io_ms 10
66# log_must set_tunable64 zfs_slow_io_events_per_second 1000
67
68# Create 20ms IOs
69log_must zinject -d $DISK -D20:100 $TESTPOOL
70log_must mkfile 1048576 /$TESTPOOL/testfile
71sync_pool $TESTPOOL
72
73log_must zinject -c all
74SLOW_IOS=$(zpool status -sp | grep "$DISK" | awk '{print $6}')
75#DELAY_EVENTS=$(zpool events | grep delay | wc -l)
76
77# if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then
78#	log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events"
79if [ $SLOW_IOS -gt 0 ] ; then
80	log_pass "Correctly saw $SLOW_IOS slow IOs"
81else
82#	log_fail "Only saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events"
83	log_fail "Only saw $SLOW_IOS slow IOs"
84fi
85