1#!/usr/local/bin/ksh93 -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) 2023 Axcient. All rights reserved. 25# Use is subject to license terms. 26# 27# $FreeBSD$ 28 29. $STF_SUITE/include/libtest.kshlib 30. $STF_SUITE/include/libgnop.kshlib 31 32################################################################################ 33# 34# __stc_assertion_start 35# 36# ID: zfsd_fault_002_pos 37# 38# DESCRIPTION: 39# If a vdev experiences delayed I/O, it will become faulted. 40# 41# 42# STRATEGY: 43# 1. Create a storage pool. Use gnop vdevs so we can inject I/O delays. 44# 2. Inject IO delays while doing IO to the pool. 45# 3. Verify that the vdev becomes FAULTED. 46# 4. ONLINE it and verify that it resilvers and joins the pool. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# __stc_assertion_end 53# 54############################################################################### 55 56verify_runnable "global" 57 58log_assert "ZFS will fault a vdev that experiences delayed I/O" 59 60ensure_zfsd_running 61 62DISK0_NOP=${DISK0}.nop 63DISK1_NOP=${DISK1}.nop 64 65log_must create_gnops $DISK0 $DISK1 66 67for type in "raidz" "mirror"; do 68 log_note "Testing raid type $type" 69 70 # Create a pool on the supplied disks 71 create_pool $TESTPOOL $type "$DISK0_NOP" "$DISK1_NOP" 72 log_must $ZFS create $TESTPOOL/$TESTFS 73 74 # Cause some IO delays writing to the pool 75 while true; do 76 # ZFS currently considers an I/O to be "slow" if it's delayed 77 # for 30 seconds (zio_slow_io_ms). 78 log_must gnop configure -d 31000 -x 100 "$DISK1_NOP" 79 $DD if=/dev/zero bs=128k count=1 >> \ 80 /$TESTPOOL/$TESTFS/$TESTFILE 2> /dev/null 81 $FSYNC /$TESTPOOL/$TESTFS/$TESTFILE 82 # Check to see if the pool is faulted yet 83 $ZPOOL status $TESTPOOL | grep -q 'state: DEGRADED' 84 if [ $? == 0 ] 85 then 86 log_note "$TESTPOOL got degraded" 87 $ZPOOL status -s $TESTPOOL 88 break 89 fi 90 done 91 92 log_must check_state $TESTPOOL $TMPDISK "FAULTED" 93 94 log_must gnop configure -x 0 "$DISK1_NOP" 95 destroy_pool $TESTPOOL 96 log_must $RM -rf /$TESTPOOL 97done 98 99log_pass 100