4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
27 # Verify the number of IO and checksum events match the error counters
31 # 1. Create a raidz or mirror pool
32 # 2. Inject read/write IO errors or checksum errors
33 # 3. Verify the number of errors in zpool status match the corresponding
34 # number of error events.
35 # 4. Repeat for all combinations of raidz/mirror and io/checksum errors.
38 . $STF_SUITE/include/libtest.shlib
40 verify_runnable "both"
42 MOUNTDIR=$TEST_BASE_DIR/mount
43 VDEV1=$TEST_BASE_DIR/file1
44 VDEV2=$TEST_BASE_DIR/file2
45 VDEV3=$TEST_BASE_DIR/file3
47 FILESIZE=$((20 * 1024 * 1024))
48 OLD_CHECKSUMS=$(get_tunable CHECKSUM_EVENTS_PER_SECOND)
49 OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX)
53 log_must set_tunable64 CHECKSUM_EVENTS_PER_SECOND $OLD_CHECKSUMS
54 log_must set_tunable64 ZEVENT_LEN_MAX $OLD_LEN_MAX
56 log_must zinject -c all
57 log_must zpool events -c
58 if poolexists $POOL ; then
59 log_must destroy_pool $POOL
61 log_must rm -f $VDEV1 $VDEV2 $VDEV3
64 log_assert "Check that the number of zpool errors match the number of events"
68 # Set our thresholds high so we never ratelimit or drop events.
69 set_tunable64 CHECKSUM_EVENTS_PER_SECOND 20000
70 set_tunable64 ZEVENT_LEN_MAX 20000
72 log_must truncate -s $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3
73 log_must mkdir -p $MOUNTDIR
75 # Run error test on a specific type of pool
77 # $1: pool - raidz, mirror
78 # $2: test type - corrupt (checksum error), io
86 log_note "Testing $ERR $RW on $POOLTYPE"
87 log_must zpool create -f -m $MOUNTDIR -o failmode=continue $POOL $POOLTYPE $VDEV1 $VDEV2 $VDEV3
88 log_must zpool events -c
89 log_must zfs set compression=off $POOL
91 if [ "$RW" == "read" ] ; then
92 log_must mkfile $FILESIZE $MOUNTDIR/file
95 log_must zinject -d $VDEV1 -e $ERR -T $RW -f 100 $POOL
97 if [ "$RW" == "write" ] ; then
98 log_must mkfile $FILESIZE $MOUNTDIR/file
99 log_must zpool sync $POOL
101 log_must zpool scrub $POOL
105 log_must zinject -c all
107 # Wait for the pool to settle down and finish resilvering (if
108 # necessary). We want the errors to stop incrementing before we
109 # check the error and event counts.
110 while is_pool_resilvering $POOL ; do
114 out="$(zpool status -p | grep $VDEV1)"
116 if [ "$ERR" == "corrupt" ] ; then
117 events=$(zpool events | grep checksum | wc -l)
118 val=$(echo "$out" | awk '{print $5}')
120 elif [ "$ERR" == "io" ] ; then
121 allevents=$(zpool events | grep io)
122 events=$(echo "$allevents" | wc -l)
123 if [ "$RW" == "read" ] ; then
125 val=$(echo "$out" | awk '{print $3}')
128 val=$(echo "$out" | awk '{print $4}')
132 if [ -z "$val" -o $val -eq 0 -o -z "$events" -o $events -eq 0 ] ; then
133 log_fail "Didn't see any errors or events ($val/$events)"
136 if [ $val -ne $events ] ; then
137 log_fail "$val $POOLTYPE $str errors != $events events"
139 log_note "$val $POOLTYPE $str errors == $events events"
142 log_must zpool destroy $POOL
145 # Test all types of errors on mirror and raidz pools
146 for pooltype in mirror raidz ; do
147 do_test $pooltype corrupt read
148 do_test $pooltype io read
149 do_test $pooltype io write
152 log_pass "The number of errors matched the number of events"