6 # This file and its contents are supplied under the terms of the
7 # Common Development and Distribution License ("CDDL"), version 1.0.
8 # You may only use this file in accordance with the terms of version
11 # A full copy of the text of the CDDL should have accompanied this
12 # source. A copy of the CDDL is also available via the Internet at
13 # http://www.illumos.org/license/CDDL.
19 # Copyright (c) 2024 by Lawrence Livermore National Security, LLC.
22 . $STF_SUITE/include/libtest.shlib
26 # Verify 'zpool status -e' only shows unhealthy devices.
30 # 2. Force DEGRADE, FAULT, or inject slow IOs for vdevs
31 # 3. Verify vdevs are reported correctly with -e and -s
32 # 4. Verify parents are reported as DEGRADED
33 # 5. Verify healthy children are not reported
38 log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO
40 poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2
41 log_must rm -f $all_vdevs
44 log_assert "Verify 'zpool status -e'"
48 all_vdevs=$(echo $TESTDIR/vdev{1..6})
49 log_must mkdir -p $TESTDIR
50 log_must truncate -s $MINVDEVSIZE $all_vdevs
52 OLD_SLOW_IO=$(get_tunable ZIO_SLOW_IO_MS)
54 for raid_type in "draid2:3d:6c:1s" "raidz2"; do
56 log_must zpool create -f $TESTPOOL2 $raid_type $all_vdevs
58 # Check DEGRADED vdevs are shown.
59 log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev4 "ONLINE"
60 log_must zinject -d $TESTDIR/vdev4 -A degrade $TESTPOOL2
61 log_must eval "zpool status -e $TESTPOOL2 | grep $TESTDIR/vdev4 | grep DEGRADED"
63 # Check FAULTED vdevs are shown.
64 log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev5 "ONLINE"
65 log_must zinject -d $TESTDIR/vdev5 -A fault $TESTPOOL2
66 log_must eval "zpool status -e $TESTPOOL2 | grep $TESTDIR/vdev5 | grep FAULTED"
68 # Check no ONLINE vdevs are shown
69 log_mustnot eval "zpool status -e $TESTPOOL2 | grep ONLINE"
71 # Check no ONLINE slow vdevs are show. Then mark IOs greater than
72 # 10ms slow, delay IOs 20ms to vdev6, check slow IOs.
73 log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev6 "ONLINE"
74 log_mustnot eval "zpool status -es $TESTPOOL2 | grep ONLINE"
76 log_must set_tunable64 ZIO_SLOW_IO_MS 10
77 log_must zinject -d $TESTDIR/vdev6 -D20:100 $TESTPOOL2
78 log_must mkfile 1048576 /$TESTPOOL2/testfile
80 log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO
82 # Check vdev6 slow IOs are only shown when requested with -s.
83 log_mustnot eval "zpool status -e $TESTPOOL2 | grep $TESTDIR/vdev6 | grep ONLINE"
84 log_must eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev6 | grep ONLINE"
86 # Pool level and top-vdev level status must be DEGRADED.
87 log_must eval "zpool status -e $TESTPOOL2 | grep $TESTPOOL2 | grep DEGRADED"
88 log_must eval "zpool status -e $TESTPOOL2 | grep $raid_type | grep DEGRADED"
90 # Check that healthy vdevs[1-3] aren't shown with -e.
91 log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev1 "ONLINE"
92 log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev2 "ONLINE"
93 log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev3 "ONLINE"
94 log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev1 | grep ONLINE"
95 log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev2 | grep ONLINE"
96 log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev3 | grep ONLINE"
98 log_must zinject -c all
99 log_must zpool status -es $TESTPOOL2
101 zpool destroy $TESTPOOL2
104 log_pass "Verify zpool status -e shows only unhealthy vdevs"