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# Copyright (c) 2018 Lawrence Livermore National Security, LLC.
23
24. $STF_SUITE/include/libtest.shlib
25. $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
26
27#
28# DESCRIPTION:
29#	zpool status should print "(repairing)" on drives with errors found
30#	while scrubbing.
31#
32# STRATEGY:
33#	1. Create a file (already done in setup.ksh)
34#	2. Inject read errors on one vdev
35#	3. Run a scrub
36#	4. Verify we see "(repairing)" on the bad vdev
37#
38
39verify_runnable "global"
40
41log_assert "Verify we see '(repairing)' while scrubbing a bad vdev."
42
43function cleanup
44{
45	log_must zinject -c all
46	log_must set_tunable64 zfs_scan_vdev_limit $ZFS_SCAN_VDEV_LIMIT_DEFAULT
47	zpool scrub -s $TESTPOOL || true
48}
49
50log_onexit cleanup
51
52# A file is already created in setup.ksh.  Inject read errors on the first disk.
53log_must zinject -d $DISK1 -e io -T read -f 100 $TESTPOOL
54
55# Make the scrub slow
56log_must zinject -d $DISK1 -D10:1 $TESTPOOL
57log_must set_tunable64 zfs_scan_vdev_limit $ZFS_SCAN_VDEV_LIMIT_SLOW
58
59log_must zpool scrub $TESTPOOL
60
61# Wait for the scrub to show '(repairing)'.  Timeout after 10 sec if it doesn't
62# show it.
63for i in {0..100} ; do
64	if ! is_pool_scrubbing $TESTPOOL ; then
65		break
66	fi
67
68	if zpool status | grep "$DISK1" | grep -q '(repairing)' ; then
69		log_pass "Correctly saw '(repairing)' while scrubbing"
70	fi
71
72	sleep 0.1
73done
74log_fail "Never saw '(repairing)' while scrubbing"
75