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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# Copyright 2012,2013 Spectra Logic Corporation. All rights reserved. 28# Use is subject to license terms. 29# 30# Portions taken from: 31 32. $STF_SUITE/tests/hotspare/hotspare.kshlib 33. $STF_SUITE/tests/zfsd/zfsd.kshlib 34. $STF_SUITE/include/libtest.kshlib 35. $STF_SUITE/include/libgnop.kshlib 36 37log_assert "ZFSD will automatically replace a SAS disk that disappears and reappears in the same location, with the same devname" 38 39ensure_zfsd_running 40 41set_disks 42 43typeset REMOVAL_DISK=$DISK0 44typeset REMOVAL_NOP=${DISK0}.nop 45typeset OTHER_DISKS="${DISK1} ${DISK2}" 46typeset ALLDISKS="${DISK0} ${DISK1} ${DISK2}" 47typeset ALLNOPS=${ALLDISKS//~(E)([[:space:]]+|$)/.nop\1} 48 49log_must create_gnops $ALLDISKS 50for type in "raidz" "mirror"; do 51 # Create a pool on the supplied disks 52 create_pool $TESTPOOL $type $ALLNOPS 53 log_must $ZFS create $TESTPOOL/$TESTFS 54 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 55 56 # Disable the first disk. 57 log_must destroy_gnop $REMOVAL_DISK 58 log_must wait_for_pool_removal 20 59 60 # Write out data to make sure we can do I/O after the disk failure 61 log_must $DD if=/dev/zero of=$TESTDIR/$TESTFILE bs=1m count=1 62 log_must $FSYNC $TESTDIR/$TESTFILE 63 64 # Check to make sure ZFS sees the disk as removed 65 wait_for_pool_dev_state_change 20 $REMOVAL_NOP REMOVED 66 67 # Re-enable the disk 68 log_must create_gnop $REMOVAL_DISK 69 70 # Disk should auto-join the zpool & be resilvered. 71 wait_for_pool_dev_state_change 20 $REMOVAL_NOP ONLINE 72 wait_until_resilvered 73 74 $ZPOOL status $TESTPOOL 75 destroy_pool $TESTPOOL 76 log_must $RM -rf /$TESTPOOL 77done 78 79log_pass 80