Index: projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib (revision 323038) @@ -1,185 +1,184 @@ # # Copyright (c) 2010 Spectra Logic Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions, and the following disclaimer, # without modification. # 2. Redistributions in binary form must reproduce at minimum a disclaimer # substantially similar to the "NO WARRANTY" disclaimer below # ("Disclaimer") and any redistribution must be conditioned upon # including a substantially similar Disclaimer requirement for further # binary redistribution. # # NO WARRANTY # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # -# $Id: //SpectraBSD/stable/tests/sys/cddl/zfs/include/libsas.kshlib#2 $ # $FreeBSD$ # # Get all PHYs for a given expander. # Returns formatting suitable for iteration. function get_all_phys { typeset expander=$1 camcontrol smpphylist $expander -q | awk '{print $1" "$NF}' | \ tr -d '()' | tr ',' ' ' | tr '\n' ',' } # # Given a disk (e.g. /dev/da0 or da0), determine the following: # - Does it exist in CAM? # - Is it attached to an expander and can we find that expander? # Returns two variables: # EXPANDER -- The peripheral we need to talk to to communicate with the # expander that is connected to the given disk. # PHY -- The phy on the expander that we need to talk to. # function find_verify_sas_disk { typeset DISK=${1##*/} typeset i [ ! -c /dev/$DISK ] && log_fail "\"/dev/$DISK\" is not a char device" # Make sure this device exists. An inquiry should always succeed, # even if there is a pending error. log_must camcontrol inquiry $DISK > /dev/null # Pull the list of every peripheral in the system, except for # peripherals that are attached to the disk we're looking for typeset PASSLIST=`camcontrol devlist |awk '{print $NF}' |\ egrep -v ".*$DISK[^[:digit:]]" |tr -d '()' |awk -F, '{print $1}'` typeset FOUND=0 for i in $PASSLIST; do # Make sure this particular device supports SMP. If not, # no big deal, keep going. camcontrol smprg $i > /dev/null 2>&1 [ $? -ne 0 ] && continue # Make sure this particular device is an Enclosure Services # device. That way, we won't wind up removing the device # we're trying to operate on. # XXX this will need to change once CAM is changed to # include SMP targets in the topology. This merely takes # advantage of the fact that most (all?) expanders include # a SES device. camcontrol inquiry $i |grep "Enclosure Services" > /dev/null [ $? -ne 0 ] && continue # For every peripheral, we go through and pull out the # list of devices and their phys that we can see via this # peripheral. IFS="," for j in $(get_all_phys $i); do IFS=", \n" set -A PERIPHLIST $j unset IFS typeset NUMPERIPHS=${#PERIPHLIST[*]} ((k=1)) while [ $k -lt $NUMPERIPHS ]; do if [ "${PERIPHLIST[$k]}" = "$DISK" ]; then # echo "found $DISK PHY = ${PERIPHLIST[0]} on $i" FOUND=1 export EXPANDER=$i export PHY=${PERIPHLIST[0]} break; fi ((k=k+1)) done if [ $FOUND != 0 ]; then break; fi done unset IFS [ $FOUND -ne 0 ] && break done [ $FOUND -eq 0 ] && log_fail "Could not find PHY for disk $DISK" } # # Given an expander and phy number, find the disk device name. # function find_disk_by_phy { typeset EXPANDER=$1 typeset PHY=$2 typeset FOUND=0 unset FOUNDDISK IFS="," for j in $(get_all_phys $EXPANDER); do IFS=", \n" set -A PERIPHLIST $j unset IFS [ "${PERIPHLIST[0]}" != "$PHY" ] && continue typeset NUMPERIPHS=${#PERIPHLIST[*]} for ((k=1; $k < $NUMPERIPHS; k=$k + 1)); do ((PSTOP=$NUMPERIPHS-1)) if [ "${PERIPHLIST[$k]%%[0-9]*}" != "pass" ] || \ [ "$k" -eq $PSTOP ]; then export FOUNDDISK=${PERIPHLIST[$k]} break; fi done FOUND=1 break; done } # Given an expander and phy on that expander, disable the phy. # This function will exit (via log_fail) if it can't send the disable # request. function disable_sas_disk { typeset EXPANDER=$1 typeset PHY=$2 # Disable the phy for this particular device log_must camcontrol smppc $EXPANDER -v -p $PHY -o disable } # Given an expander and phy on that expander, enable the phy. # This function will exit (via log_fail) if it can't send the link reset # request. function enable_sas_disk { typeset EXPANDER=$1 typeset PHY=$2 # Send a link reset to bring the device back log_must camcontrol smppc $EXPANDER -p $PHY -o linkreset } function rescan_disks { if [[ -z "$1" ]]; then log_must camcontrol rescan all >/dev/null return fi for device in $(echo $* | sort -u); do log_must camcontrol rescan $device >/dev/null done } Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh (revision 323038) @@ -1,177 +1,176 @@ #!/usr/local/bin/ksh93 # # Copyright (c) 2010 Spectra Logic Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions, and the following disclaimer, # without modification. # 2. Redistributions in binary form must reproduce at minimum a disclaimer # substantially similar to the "NO WARRANTY" disclaimer below # ("Disclaimer") and any redistribution must be conditioned upon # including a substantially similar Disclaimer requirement for further # binary redistribution. # # NO WARRANTY # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # -# $Id$ # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib . $STF_SUITE/tests/hotspare/hotspare.kshlib # Reproduction script for Rally DE189: # https://rally1.rallydev.com/#/9096795496d/detail/defect/13345916506 # # To reproduce, from Keith's email: # 1. Create a 3 drive raid. # 2. Disable a drive # 3. Let a Spare take over # 4. Disable that Spare when it is done rebuilding. # 5. Let 2nd spare finish rebuilding # 6. Enable the first spare # 7. Enable the original drive # 8. Destroy the pool. cleanup() { [[ $DISK0_PHY != 0 ]] && enable_sas_disk $DISK0_EXPANDER $DISK0_PHY [[ $SPARE0_PHY != 0 ]] && enable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY [[ $SPARE1_PHY != 0 ]] && enable_sas_disk $SPARE1_EXPANDER $SPARE1_PHY rescan_disks if poolexists $TESTPOOL; then # Test failed, provide something useful. log_note "For reference, here is the final $TESTPOOL status:" zpool status $TESTPOOL log_must destroy_pool $TESTPOOL fi } log_onexit cleanup trap cleanup TERM INT typeset -A MEMBERS typeset -A SPARES typeset DISK0_EXPANDER=0 typeset DISK0_PHY=0 typeset SPARE0_EXPANDER=0 typeset SPARE0_PHY=0 typeset SPARE1_EXPANDER=0 typeset SPARE1_PHY=0 for disk in $DISKS; do if [[ $DISK0_PHY == 0 ]]; then find_verify_sas_disk $disk DISK0_PHY=$PHY DISK0_EXPANDER=$EXPANDER DISK0_NAME=$disk set -A MEMBERS "${MEMBERS[@]}" $disk continue fi if [[ $SPARE0_PHY == 0 ]]; then find_verify_sas_disk $disk SPARE0_PHY=$PHY SPARE0_EXPANDER=$EXPANDER SPARE0_NAME=$disk set -A SPARES "${SPARES[@]}" $disk continue fi if [[ $SPARE1_PHY == 0 ]]; then find_verify_sas_disk $disk SPARE1_PHY=$PHY SPARE1_EXPANDER=$EXPANDER SPARE1_NAME=$disk set -A SPARES "${SPARES[@]}" $disk continue fi # Already filled those positions? Add disks to the raidz. if [[ ${#DISKS[*]} -lt 3 ]]; then find_verify_sas_disk $disk [[ -z "$DISK1_NAME" ]] && DISK1_NAME=$disk DISK1_LONG_NAME=`find_disks ${DISK1_NAME}` DISK1_SHORT_NAME=${DISK1_LONG_NAME##/dev/} set -A MEMBERS "${MEMBERS[@]}" $disk continue fi break done # Remove labels etc. from all the disks we're about to use. poolexists && log_must destroy_pool $TESTPOOL cleanup_devices ${MEMBERS[*]} ${SPARES[*]} log_must $ZPOOL create -f $TESTPOOL raidz1 ${MEMBERS[@]} spare ${SPARES[@]} DISK0_GUID=$(get_disk_guid $DISK0_NAME) log_must disable_sas_disk $DISK0_EXPANDER $DISK0_PHY log_must $ZPOOL replace $TESTPOOL $DISK0_GUID $SPARE0_NAME wait_until_resilvered SPARE0_GUID=$(get_disk_guid $SPARE0_NAME) log_must disable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY log_must $ZPOOL replace $TESTPOOL $SPARE0_GUID $SPARE1_NAME wait_until_resilvered log_must enable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY log_must enable_sas_disk $DISK0_EXPANDER $DISK0_PHY log_must rescan_disks log_must destroy_pool $TESTPOOL # Screen scrape the 'zpool import' output to ensure that the pool doesn't # show up, since it's been destroyed. badpoolstate=0 $ZPOOL import | \ while read word1 word2 rest; do echo "$word1 $word2 $rest" case "$word1 $word2" in "pool: $TESTPOOL") (( badpoolstate += 1 )) ;; "$DISK1_LONG_NAME ONLINE") (( badpoolstate += 2 )) ;; "$DISK1_SHORT_NAME ONLINE") (( badpoolstate += 2 )) ;; *) ;; esac done case $badpoolstate in 0) log_pass ;; 1) log_note "Destroyed pool visible, but probably another pool" log_pass ;; 2) log_fail "One of our disks is visible but pool is not?!" ;; 3) log_fail "Destroyed pool visible!" ;; *) log_fail "Unexpected output. Update the test" ;; esac # Bad output looks like this: # pool: testpool.2358 # id: 5289863802080396071 # state: UNAVAIL # status: One or more devices are missing from the system. # action: The pool cannot be imported. Attach the missing # devices and try again. # see: http://illumos.org/msg/ZFS-8000-6X # config: # # testpool.2358 UNAVAIL missing device # raidz1-0 DEGRADED # spare-0 UNAVAIL # 4564766431272474500 FAULTED corrupted data # 1988887717739330825 FAULTED corrupted data # da4 ONLINE # da5 ONLINE # spares # 1988887717739330825 # da3 Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/cleanup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/cleanup.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/cleanup.ksh (revision 323038) @@ -1,39 +1,38 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)cleanup.ksh 1.2 07/01/09 SMI" # -# $Id: //SpectraBSD/stable/tests/sys/cddl/zfs/tests/sas_phy_thrash/cleanup.ksh#2 $ # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib verify_runnable "global" # Rotate logs now, because this test can generate a great volume of log entries newsyslog default_cleanup Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash.cfg =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash.cfg (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash.cfg (revision 323038) @@ -1,36 +1,35 @@ # # Copyright (c) 2010 Spectra Logic Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions, and the following disclaimer, # without modification. # 2. Redistributions in binary form must reproduce at minimum a disclaimer # substantially similar to the "NO WARRANTY" disclaimer below # ("Disclaimer") and any redistribution must be conditioned upon # including a substantially similar Disclaimer requirement for further # binary redistribution. # # NO WARRANTY # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # -# $Id: //SpectraBSD/stable/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash.cfg#2 $ # $FreeBSD$ # export SAS_MIN_DEFAULT_DISKS=8 export SAS_DEFAULT_TIME=360 ((SAS_MAX_TIME=(SAS_MIN_DEFAULT_DISKS * SAS_DEFAULT_TIME) + 30)) export STF_TIMEOUT=$SAS_MAX_TIME Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash_001_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash_001_pos.ksh (revision 323038) @@ -1,163 +1,162 @@ #!/usr/local/bin/ksh93 # # Copyright (c) 2010 Spectra Logic Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions, and the following disclaimer, # without modification. # 2. Redistributions in binary form must reproduce at minimum a disclaimer # substantially similar to the "NO WARRANTY" disclaimer below # ("Disclaimer") and any redistribution must be conditioned upon # including a substantially similar Disclaimer requirement for further # binary redistribution. # # NO WARRANTY # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # -# $Id: //SpectraBSD/stable/tests/sys/cddl/zfs/tests/sas_phy_thrash/sas_phy_thrash_001_pos.ksh#2 $ # $FreeBSD$ # . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib typeset -i NUM_FAILURES=0 export NUM_FAILURES # Cleanup function. Kill each of the children, they will re-enable the PHY # they're working on. function docleanup { for CPID in $CHILDREN do echo "Killing $CPID" kill $CPID done } # If we get killed, try to re-enable the PHY we were toggling. function diskcleanup { log_note "Got a signal, sending linkreset to $EXPANDER phy $PHY" camcontrol smppc $EXPANDER -o linkreset -p $PHY exit 0 } # Wait for the timeout, and then kill the child processes. function disktimeout { log_note "disktimeout process waiting $1 seconds" sleep $1 docleanup } export CHILDREN="" export FAILFILES="" log_onexit docleanup typeset i=0 typeset -i num_disks_used=0 for i in $DISKS do # See if this disk is attached to a parent that supports SMP # XXX this only works with the current scheme where SMP commands get # sent to a device or its parent, if the device doesn't support SMP camcontrol smprg $i > /dev/null 2>&1 if [ $? != 0 ]; then continue fi # Find the expander and PHY that this disk is attached to, if any. # We will exit from here if there is a failure. find_verify_sas_disk $i typeset -i x=0 log_note "running test on $i on $EXPANDER phy $PHY" export FAILFILE=$TMPDIR/${EXPANDER}.${PHY}.failed trap diskcleanup INT TERM && rm -f $FAILFILE && while `true`; do ((x=x+1)) log_note "attempt number $x on $EXPANDER phy $PHY" camcontrol smppc $EXPANDER -v -o disable -p $PHY if [ $? != 0 ]; then log_note "Failed to disable $EXPANDER phy $PHY" echo "Expander $EXPANDER phy $PHY failed" >> $FAILFILE break fi $SLEEP 10 camcontrol smppc $EXPANDER -v -o linkreset -p $PHY if [ $? != 0 ]; then log_note "Failed to reset $EXPANDER phy $PHY" echo "Expander $EXPANDER phy $PHY failed" >> $FAILFILE break fi $SLEEP 10 find_disk_by_phy $EXPANDER $PHY [ -z "$FOUNDDISK" ] && \ log_fail "Disk for ${EXPANDER}:${PHY} didn't return" camcontrol inquiry $FOUNDDISK -v if [ $? != 0 ]; then log_note "Failed on $EXPANDER phy $PHY attempt $x" echo "Expander $EXPANDER phy $PHY failed" >> $FAILFILE break fi done & CHILDREN="$CHILDREN $!" FAILFILES="$FAILFILES $FAILFILE" ((num_disks_used++)) done # The minimum sleep time is 3 minutes for 8 or more disks. For fewer # disks, we need to go longer to generate the number of events necessasry # to trigger the bug. Scale it up by the number of disks we actually have. typeset -i sleep_time=$SAS_DEFAULT_TIME if [ $num_disks_used -lt $SAS_MIN_DEFAULT_DISKS ]; then ((sleep_time *= (SAS_MIN_DEFAULT_DISKS / num_disks_used))) fi # XXX KDM need to stop the entire test as soon as any one of the child # processes fails. How does that work in the test framework? if [ $num_disks_used -gt 0 ]; then log_note "Tests queued on $num_disks_used disks" log_note "Waiting $sleep_time seconds for potential driver failure" disktimeout $sleep_time & wait # sleep $sleep_time for i in $FAILFILES; do typeset FILEBASE=${i%%.failed} FILEBASE=${FILEBASE##$TMPDIR/} if [ -f $i ]; then log_note "Test of $FILEBASE failed" ((NUM_FAILURES=NUM_FAILURES+1)) rm -f $i else log_note "Test of $FILEBASE passed" fi done if [ $NUM_FAILURES -gt 0 ]; then log_fail "Saw $NUM_FAILURES failures" else log_note "Number of failures: $NUM_FAILURES" log_pass fi else log_unsupported "No tests queued, no SMP-capable devices found" fi Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/setup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/setup.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/sas_phy_thrash/setup.ksh (revision 323038) @@ -1,49 +1,48 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)setup.ksh 1.3 09/05/19 SMI" # -# $Id: //SpectraBSD/stable/tests/sys/cddl/zfs/tests/sas_phy_thrash/setup.ksh#2 $ # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib . ${STF_SUITE}/include/libsas.kshlib verify_runnable "global" echo "list of disks: $DISKS" # Make sure that all of the disks that we've been given are attached to a # SAS expander, and that we can find the phy they're attached to. This # function will cause the script to exit if it fails. for disk in $DISKS do find_verify_sas_disk $disk done # Rotate logs now, because this test can generate a great volume of log entries newsyslog log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/cleanup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/cleanup.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/cleanup.ksh (revision 323038) @@ -1,37 +1,36 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/soft_errors/cleanup.ksh#1 $ # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib verify_runnable "global" # Rotate logs now, because this test can generate a great volume of log entries newsyslog default_cleanup Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/setup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/setup.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/setup.ksh (revision 323038) @@ -1,47 +1,46 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/soft_errors/setup.ksh#1 $ # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib . ${STF_SUITE}/include/libsas.kshlib verify_runnable "global" echo "list of disks: $DISKS" # Make sure that all of the disks that we've been given are attached to a # SAS expander, and that we can find the phy they're attached to. This # function will cause the script to exit if it fails. for disk in $DISKS do find_verify_sas_disk $disk done # Rotate logs now, because this test can generate a great volume of log entries newsyslog log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh (revision 323038) @@ -1,91 +1,90 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # -# $Id: $ # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_degrade_001_pos # # DESCRIPTION: # If a vdev experiences checksum errors, it will become degraded. # # # STRATEGY: # 1. Create a storage pool. Only use the file vdevs because it is easy to # generate checksum errors on them. # 2. Mostly fill the pool with data. # 3. Corrupt it by DDing to the underlying vdev # 4. Verify that the vdev becomes DEGRADED. # 5. ONLINE it and verify that it resilvers and joins the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2012-08-09) # # __stc_assertion_end # ############################################################################### verify_runnable "global" VDEV0=${TMPDIR}/file0.${TESTCASE_ID} VDEV1=${TMPDIR}/file1.${TESTCASE_ID} VDEVS="${VDEV0} ${VDEV1}" TESTFILE=/$TESTPOOL/testfile VDEV_SIZE=192m function cleanup { destroy_pool $TESTPOOL $RM -f $VDEVS } log_assert "ZFS will degrade a vdev that produces checksum errors" log_onexit cleanup log_must create_vdevs $VDEV0 $VDEV1 ensure_zfsd_running for type in "raidz" "mirror"; do log_note "Testing raid type $type" create_pool $TESTPOOL $type ${VDEVS} corrupt_pool_vdev $TESTPOOL $VDEV1 $TESTFILE destroy_pool $TESTPOOL done cleanup log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh (revision 323038) @@ -1,103 +1,102 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2012-2014 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # -# $Id: $ # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_degrade_002_pos # # DESCRIPTION: # If an active hotspare experiences checksum errors, it will become degraded. # # # STRATEGY: # 1. Create a storage pool with a hotspare. Only use the file vdevs because # it is easy to generate checksum errors on them. # 2. fault a vdev to active the hotspare # 3. Mostly fill the pool with data. # 4. Corrupt it by DDing to the hotspare's underlying file. # 5. Verify that the hotspare becomes DEGRADED. # 6. ONLINE it and verify that it resilvers and joins the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2014-05-13) # # __stc_assertion_end # ############################################################################### verify_runnable "global" VDEV0=${TMPDIR}/file0.${TESTCASE_ID} VDEV1=${TMPDIR}/file1.${TESTCASE_ID} SPARE_VDEV=${TMPDIR}/file2.${TESTCASE_ID} BASIC_VDEVS="${VDEV0} ${VDEV1}" VDEVS="${BASIC_VDEVS} ${SPARE_VDEV}" TESTFILE=/$TESTPOOL/testfile VDEV_SIZE=192m function cleanup { destroy_pool $TESTPOOL $RM -f $VDEVS } log_assert "ZFS will degrade a spare vdev that produces checksum errors" log_onexit cleanup ensure_zfsd_running log_must create_vdevs $VDEV0 $VDEV1 $SPARE_VDEV for type in "mirror" "raidz"; do log_note "Testing raid type $type" create_pool $TESTPOOL $type ${BASIC_VDEVS} spare ${SPARE_VDEV} # Activate the hotspare $ZINJECT -d ${VDEV0} -A fault $TESTPOOL # ZFSD can take up to 60 seconds to replace a failed device # (though it's usually faster). wait_for_pool_dev_state_change 60 $SPARE_VDEV INUSE corrupt_pool_vdev $TESTPOOL $SPARE_VDEV $TESTFILE destroy_pool $TESTPOOL done cleanup log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_fault_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_fault_001_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_fault_001_pos.ksh (revision 323038) @@ -1,164 +1,163 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/soft_errors/soft_errors_001_pos.ksh#2 $ # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_fault_001_pos # # DESCRIPTION: # If a vdev experiences IO errors, it will become faulted. # # # STRATEGY: # 1. Create a storage pool. Only use the da driver (FreeBSD's SCSI disk # driver) because it has a special interface for simulating IO errors. # 2. Inject IO errors while doing IO to the pool. # 3. Verify that the vdev becomes FAULTED. # 4. ONLINE it and verify that it resilvers and joins the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2012-08-09) # # __stc_assertion_end # ############################################################################### verify_runnable "global" function cleanup { # Disable error injection, if still active sysctl kern.cam.da.$TMPDISKNUM.error_inject=0 > /dev/null if poolexists $TESTPOOL; then # We should not get here if the test passed. Print the output # of zpool status to assist in debugging. $ZPOOL status # Clear out artificially generated errors and destroy the pool $ZPOOL clear $TESTPOOL destroy_pool $TESTPOOL fi } log_assert "ZFS will fault a vdev that produces IO errors" log_onexit cleanup ensure_zfsd_running # Make sure that at least one of the disks is using the da driver, and use # that disk for inject errors typeset TMPDISK="" for d in $DISKS do b=`basename $d` if test ${b%%[0-9]*} == da then TMPDISK=$b TMPDISKNUM=${b##da} break fi done if test -z $TMPDISK then log_unsupported "This test requires at least one disk to use the da driver" fi for type in "raidz" "mirror"; do log_note "Testing raid type $type" # Create a pool on the supplied disks create_pool $TESTPOOL $type $DISKS log_must $ZFS create $TESTPOOL/$TESTFS # Cause some IO errors writing to the pool while true; do # Running zpool status after every dd operation is too slow. # So we will run several dd's in a row before checking zpool # status. sync between dd operations to ensure that the disk # gets IO for ((i=0; $i<64; i=$i+1)); do sysctl kern.cam.da.$TMPDISKNUM.error_inject=1 > \ /dev/null $DD if=/dev/zero bs=128k count=1 >> \ /$TESTPOOL/$TESTFS/$TESTFILE 2> /dev/null $FSYNC /$TESTPOOL/$TESTFS/$TESTFILE done # Check to see if the pool is faulted yet $ZPOOL status $TESTPOOL | grep -q 'state: DEGRADED' if [ $? == 0 ] then log_note "$TESTPOOL got degraded" break fi done log_must check_state $TESTPOOL $TMPDISK "FAULTED" #find the failed disk guid typeset FAILED_VDEV=`$ZPOOL status $TESTPOOL | awk "/^[[:space:]]*$TMPDISK[[:space:]]*FAULTED/ {print \\$1}"` # Reattach the failed disk $ZPOOL online $TESTPOOL $FAILED_VDEV > /dev/null if [ $? != 0 ]; then log_fail "Could not reattach $FAILED_VDEV" fi # Verify that the pool resilvers and goes to the ONLINE state for (( retries=60; $retries>0; retries=$retries+1 )) do $ZPOOL status $TESTPOOL | egrep -q "scan:.*resilvered" RESILVERED=$? $ZPOOL status $TESTPOOL | egrep -q "state:.*ONLINE" ONLINE=$? if test $RESILVERED -a $ONLINE then break fi $SLEEP 2 done if [ $retries == 0 ] then log_fail "$TESTPOOL never resilvered in the allowed time" fi destroy_pool $TESTPOOL log_must $RM -rf /$TESTPOOL done log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh (revision 323038) @@ -1,93 +1,92 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # # Portions taken from: # ident "@(#)replacement_001_pos.ksh 1.4 08/02/27 SMI" # -# $Id: //SpectraBSD/stable/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh#2 $ # $FreeBSD$ . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib verify_runnable "global" log_assert "Failing a disk from a SAS expander is recognized by ZFS" log_onexit autoreplace_cleanup ensure_zfsd_running child_pids="" set -A TMPDISKS $DISKS typeset REMOVAL_DISK=${TMPDISKS[0]} REMOVAL_DISK=${REMOVAL_DISK##*/} for type in "raidz" "mirror"; do # Create a pool on the supplied disks create_pool $TESTPOOL $type $DISKS log_must $ZFS create $TESTPOOL/$TESTFS log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS # Find the first disk, get the expander and phy log_note "Looking for expander and phy information for $REMOVAL_DISK" find_verify_sas_disk $REMOVAL_DISK log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" # Disable the first disk. We have to do this first, because if # there is I/O active to the disable_sas_disk $EXPANDER $PHY # Check to make sure disk is gone. find_disk_by_phy $EXPANDER $PHY [ -n "$FOUNDDISK" ] && log_fail "Disk \"$REMOVAL_DISK\" was not removed" # Write out data to make sure we can do I/O after the disk failure log_must $DD if=/dev/zero of=$TESTDIR/$TESTFILE bs=1m count=512 # Check to make sure ZFS sees the disk as removed wait_for_pool_removal 20 # Re-enable the disk, we don't want to leave it turned off log_note "Re-enabling phy $PHY on expander $EXPANDER" enable_sas_disk $EXPANDER $PHY wait_for_disk_to_reappear 20 $EXPANDER $PHY # Disk should auto-join the zpool & be resilvered. wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE wait_until_resilvered $ZPOOL status $TESTPOOL destroy_pool $TESTPOOL log_must $RM -rf /$TESTPOOL done log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_002_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_002_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_002_pos.ksh (revision 323038) @@ -1,188 +1,187 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # # Portions taken from: # ident "@(#)replacement_001_pos.ksh 1.4 08/02/27 SMI" # -# $Id$ # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib verify_runnable "global" function cleanup { reap_children destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. for CURDISK in $TMPDISKS[*]; do if [ ! -z ${EXPANDER_LIST[$CURDISK]} -a ! -z ${PHY_LIST[$CURDISK]} ]; then find_disk_by_phy ${EXPANDER_LIST[$CURDISK]} ${PHY_LIST[$CURDISK]} [ -n "$FOUNDDISK" ] && continue fi enable_sas_disk ${EXPANDER_LIST[$CURDISK]} ${PHY_LIST[$CURDISK]} done rescan_disks [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* } log_assert "A pool can come back online after all disks are failed and reactivated" log_unsupported "This test is currently unsupported, ZFS hangs when all drives fail and come back" log_onexit cleanup child_pids="" ensure_zfsd_running set -A TMPDISKS $DISKS NUMDISKS=${#TMPDISKS[*]} # Trim out any /dev prefix on the disk. ((i=0)) while [ $i -lt $NUMDISKS ]; do TMPDISKS[$i]=${TMPDISKS[$i]##*/} ((i++)); done for type in "raidz" "mirror"; do # Create a pool on the supplied disks create_pool $TESTPOOL $type $DISKS log_must $ZFS create $TESTPOOL/$TESTFS log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS unset EXPANDER_LIST typeset -A EXPANDER_LIST unset PHY_LIST typeset -A PHY_LIST # First, disable the PHYs for all of the disks. for CURDISK in ${TMPDISKS[*]}; do # Find the first disk, get the expander and phy log_note "Looking for expander and phy information for $CURDISK" find_verify_sas_disk $CURDISK # Record the expander and PHY for this particular disk, so # that we can re-enable the disk later, even if it comes # back as a different da(4) instance. EXPANDER_LIST[$CURDISK]=$EXPANDER PHY_LIST[$CURDISK]=$PHY log_note "Disabling \"$CURDISK\" on expander $EXPANDER phy $PHY" # Disable the first disk. We have to do this first, because if # there is I/O active to the disable_sas_disk $EXPANDER $PHY done rescan_disks # Now go through the list of disks, and make sure they are all gone. for CURDISK in ${TMPDISKS[*]}; do # Check to make sure disk is gone. log_mustnot camcontrol inquiry $CURDISK done # Make sure that the pool status is "UNAVAIL". We have taken all # of the drives offline, so it should be. log_must is_pool_state $TESTPOOL UNAVAIL # Now we re-enable all of the PHYs. Note that we turned off the # sleep inside enable_sas_disk, so this should quickly. for CURDISK in ${TMPDISKS[*]}; do # Re-enable the disk, we don't want to leave it turned off log_note "Re-enabling phy ${PHY_LIST[$CURDISK]} on expander ${EXPANDER_LIST[$CURDISK]}" enable_sas_disk ${EXPANDER_LIST[$CURDISK]} ${PHY_LIST[$CURDISK]} done rescan_disks unset DISK_FOUND typeset -A DISK_FOUND log_note "Checking to see whether disks have reappeared" ((retries=0)) while [ ${#DISK_FOUND[*]} -lt $NUMDISKS ] && [ $retries -lt 3 ]; do # If this isn't the first time through, give the disk a # little more time to show up. [ $retries -ne 0 ] && $SLEEP 5 for CURDISK in ${TMPDISKS[*]}; do # If we already found this disk, we don't need to # check again. Note that the new name may not be # the same as the name referenced in CURDISK. That # is why we look for the disk by expander and PHY. [ ! -z ${DISK_FOUND[$CURDISK]} ] && continue # Make sure the disk is back in the topology find_disk_by_phy ${EXPANDER_LIST[$CURDISK]} ${PHY_LIST[$CURDISK]} if [ ! -z "$FOUNDDISK" ]; then # This does serve as a mapping from the old # disk name to the new disk name. DISK_FOUND[$CURDISK]=$FOUNDDISK fi done ((retries++)) done if [ ${#DISK_FOUND[*]} -lt $NUMDISKS ]; then for CURDISK in ${TMPDISKS[*]}; do [ ! -z ${DISK_FOUND[$CURDISK]} ] && continue log_note "Disk $CURDISK has not appeared at phy $PHY_LIST[$CURDISK] on expander $EXPANDER_LIST[$CURDISK] after 20 seconds" done ((num_missing=${NUM_DISKS} - ${#DISK_FOUND[*]})) log_fail "Missing $num_missing Disks out of $NUM_DISKS Disks" else for CURDISK in ${TMPDISKS[*]}; do log_note "Disk $CURDISK is back as ${DISK_FOUND[$CURDISK]}" done # Reset our array of disks, because we may have disks that # have come back at a different ID. i.e. da0 may now be da7, # and da0 may no longer be a disk that we are authorized to use. # This is a more generic problem that we may need to tackle # with this test. We may need to reset the DISKS list itself. set -A TMPDISKS ${DISK_FOUND[*]} fi log_note "Raid type is $type" # In theory the pool should be back online. $ZPOOL status $TESTPOOL |grep ONLINE > /dev/null if [ $? != 0 ]; then log_fail "Pool $TESTPOOL is disk $TMPDISK did not automatically join the $TESTPOOL" else log_note "After reinsertion, disk is back in pool and online" fi destroy_pool $TESTPOOL log_must $RM -rf /$TESTPOOL done log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh (revision 323038) @@ -1,154 +1,153 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # # Portions taken from: # ident "@(#)replacement_001_pos.ksh 1.4 08/02/27 SMI" # -# $Id: //SpectraBSD/stable/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/zfsd/zfsd_replace_003_pos.ksh#1 $ # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib verify_runnable "global" function cleanup { # See if the phy has been disabled, and try to re-enable it if possible. [ -n "$EXPANDER0" -a -n "$PHY0" ] && enable_sas_disk $EXPANDER0 $PHY0 [ -n "$EXPANDER1" -a -n "$PHY1" ] && enable_sas_disk $EXPANDER1 $PHY1 [ -n "$EXPANDER" -a -n "$PHY" ] && enable_sas_disk $EXPANDER $PHY destroy_pool $TESTPOOL [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* } # arg1: disk devname # Leaves EXPANDER and PHY set appropriately function remove_disk { typeset DISK=$1 # Find the first disk, get the expander and phy log_note "Looking for expander and phy information for $DISK" find_verify_sas_disk $DISK log_note "Disabling \"$DISK\" on expander $EXPANDER phy $PHY" # Disable the first disk. disable_sas_disk $EXPANDER $PHY # Check to make sure disk is gone. find_disk_by_phy $EXPANDER $PHY [ -n "$FOUNDDISK" ] && log_fail "Disk \"$DISK\" was not removed" # Check to make sure ZFS sees the disk as removed wait_for_pool_dev_state_change 20 $DISK "REMOVED|UNAVAIL" } # arg1: disk's old devname # arg2: disk's expander's devname # arg3: disk's phy number # arg4: whether the devname must differ after reconnecting function reconnect_disk { typeset DISK=$1 typeset EXPANDER=$2 typeset PHY=$3 # Re-enable the disk, we don't want to leave it turned off log_note "Re-enabling phy $PHY on expander $EXPANDER" enable_sas_disk $EXPANDER $PHY log_note "Checking to see whether disk has reappeared" # Make sure the disk is back in the topology wait_for_disk_to_reappear 20 $EXPANDER $PHY prev_disk=$(find_disks $DISK) cur_disk=$(find_disks $FOUNDDISK) # If you get this, the test must be fixed to guarantee that # it will reappear with a different name. [ "${prev_disk}" = "${cur_disk}" ] && log_unsupported \ "Disk $DISK reappeared with the same devname." #Disk should have auto-joined the zpool. Verify it's status is online. wait_for_pool_dev_state_change 20 $FOUNDDISK ONLINE } log_assert "ZFSD will correctly replace disks that disappear and reappear \ with different devnames" # Outline # Create a double-parity pool # Remove two disks by disabling their SAS phys # Reenable the phys in the opposite order # Check that the disks's devnames have swapped # Verify that the pool regains its health log_onexit cleanup ensure_zfsd_running child_pids="" set -A DISKS_ARRAY $DISKS typeset DISK0=${DISKS_ARRAY[0]} typeset DISK1=${DISKS_ARRAY[1]} if [ ${DISK0##/dev/da} -gt ${DISK1##/dev/da} ]; then # Swap disks so we'll disable the lowest numbered first typeset TMP="$DISK1" DISK1="$DISK0" DISK0="$TMP" fi for type in "raidz2" "mirror"; do # Create a pool on the supplied disks create_pool $TESTPOOL $type $DISKS remove_disk $DISK0 typeset EXPANDER0=$EXPANDER typeset PHY0=$PHY remove_disk $DISK1 typeset EXPANDER1=$EXPANDER typeset PHY1=$PHY # Make sure that the pool is degraded $ZPOOL status $TESTPOOL |grep "state:" |grep DEGRADED > /dev/null if [ $? != 0 ]; then log_fail "Pool $TESTPOOL not listed as DEGRADED" fi reconnect_disk $DISK1 $EXPANDER1 $PHY1 reconnect_disk $DISK0 $EXPANDER0 $PHY0 wait_until_resilvered destroy_pool $TESTPOOL log_must $RM -rf /$TESTPOOL done log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/cleanup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/cleanup.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/cleanup.ksh (revision 323038) @@ -1,39 +1,38 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)cleanup.ksh 1.2 07/01/09 SMI" # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/sas_phy_thrash/cleanup.ksh#1 $ # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib verify_runnable "global" # Rotate logs now, because this test can generate a great volume of log entries newsyslog default_cleanup Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/setup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/setup.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/setup.ksh (revision 323038) @@ -1,49 +1,48 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)setup.ksh 1.3 09/05/19 SMI" # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/sas_phy_thrash/setup.ksh#1 $ # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib . ${STF_SUITE}/include/libsas.kshlib verify_runnable "global" echo "list of disks: $DISKS" # Make sure that all of the disks that we've been given are attached to a # SAS expander, and that we can find the phy they're attached to. This # function will cause the script to exit if it fails. for disk in $DISKS do find_verify_sas_disk $disk done # Rotate logs now, because this test can generate a great volume of log entries newsyslog log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/zvol_thrash.cfg =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/zvol_thrash.cfg (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/zvol_thrash.cfg (revision 323038) @@ -1,34 +1,33 @@ # # Copyright (c) 2010 Spectra Logic Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions, and the following disclaimer, # without modification. # 2. Redistributions in binary form must reproduce at minimum a disclaimer # substantially similar to the "NO WARRANTY" disclaimer below # ("Disclaimer") and any redistribution must be conditioned upon # including a substantially similar Disclaimer requirement for further # binary redistribution. # # NO WARRANTY # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/sas_phy_thrash/sas_phy_thrash.cfg#1 $ # $FreeBSD$ # export SAS_DEFAULT_TIME=360 export STF_TIMEOUT=900 Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/zvol_thrash_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/zvol_thrash_001_pos.ksh (revision 323037) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zvol_thrash/zvol_thrash_001_pos.ksh (revision 323038) @@ -1,180 +1,179 @@ #!/usr/local/bin/ksh93 # # Copyright (c) 2010 Spectra Logic Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions, and the following disclaimer, # without modification. # 2. Redistributions in binary form must reproduce at minimum a disclaimer # substantially similar to the "NO WARRANTY" disclaimer below # ("Disclaimer") and any redistribution must be conditioned upon # including a substantially similar Disclaimer requirement for further # binary redistribution. # # NO WARRANTY # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # -# $Id: //depot/SpectraBSD/stable/9/cddl/tools/regression/stc/src/suites/fs/zfs/tests/functional/sas_phy_thrash/sas_phy_thrash_001_pos.ksh#1 $ # $FreeBSD$ # . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib typeset -i NUM_FAILURES=0 export NUM_FAILURES # Cleanup function. Kill each of the children, they will re-enable the PHY # they're working on. function docleanup { for CPID in $CHILDREN do echo "Killing $CPID" kill $CPID done for CPID in $CHILDREN do wait $CPID done } # If we get killed, try to re-enable the PHY we were toggling. function diskcleanup { log_note "Got a signal, sending linkreset to $EXPANDER phy $PHY" camcontrol smppc $EXPANDER -o linkreset -p $PHY exit 0 } # Wait for the timeout, and then kill the child processes. function disktimeout { log_note "disktimeout process waiting $1 seconds" sleep $1 docleanup } function mk_vols { ADISKS=($DISKS) #Create an array for convenience N_DISKS=${#ADISKS[@]} if test $N_DISKS -ge 8 then #Limit number of mirrors to 4. Using more causes a panic in #make_dev_credv that has nothing to do with ZFS or ZVols. #That will be addressed by a separate test N_MIRRORS=4 else N_MIRRORS=$(($N_DISKS / 2 )) fi setup_mirrors $N_MIRRORS $DISKS for pool in `all_pools`; do # Create 4 ZVols per pool. Write a geom label to each, just so # that we have another geom class between zvol and the vdev # taster. That thwarts detection of zvols based on a geom # producer's class name, as was attempted by change 538882 for ((j=0; $j<4; j=$j+1)); do $ZFS create -V 10G $pool/testvol.$j glabel label testlabel$j /dev/zvol/$pool/testvol.$j done done } export CHILDREN="" export FAILFILES="" export POOLS="" log_onexit docleanup typeset i=0 typeset -i num_disks_used=0 log_assert "Cause frequent device removal and arrival in the prescence of" \ " zvols. ZFS should not taste them for VDev GUIDs. If it does," \ " deadlocks (SpectraLogic MST 23637) and panics (SpectraLogic BUG23665" \ " and BUG23677) may result" mk_vols for p in `all_pools` do disk=`get_disklist $p | cut -d " " -f 1` #Take the first disk in the pool # See if this disk is attached to a parent that supports SMP # XXX this only works with the current scheme where SMP commands get # sent to a device or its parent, if the device doesn't support SMP camcontrol smprg $disk > /dev/null 2>&1 if [ $? != 0 ]; then continue fi # Find the expander and PHY that this disk is attached to, if any. # We will exit from here if there is a failure. find_verify_sas_disk $disk typeset -i x=0 log_note "thrashing phy on $disk on $EXPANDER phy $PHY" export FAILFILE=$TMPDIR/${EXPANDER}.${PHY}.failed trap diskcleanup INT TERM && rm -f $FAILFILE && while `true`; do ((x=x+1)) camcontrol smppc $EXPANDER -v -o disable -p $PHY if [ $? != 0 ]; then log_note "Failed to disable $EXPANDER phy $PHY" echo "Expander $EXPANDER phy $PHY failed" >> $FAILFILE break fi $SLEEP 10 camcontrol smppc $EXPANDER -v -o linkreset -p $PHY if [ $? != 0 ]; then log_note "Failed to reset $EXPANDER phy $PHY" echo "Expander $EXPANDER phy $PHY failed" >> $FAILFILE break fi $SLEEP 10 done & CHILDREN="$CHILDREN $!" FAILFILES="$FAILFILES $FAILFILE" ((num_disks_used++)) done typeset -i sleep_time=$SAS_DEFAULT_TIME if [ $num_disks_used -gt 0 ]; then log_note "Tests queued on $num_disks_used disks" log_note "Waiting $sleep_time seconds for potential driver failure" disktimeout $sleep_time & wait for i in $FAILFILES; do typeset FILEBASE=${i%%.failed} FILEBASE=${FILEBASE##$TMPDIR/} if [ -f $i ]; then log_note "Test of $FILEBASE failed" ((NUM_FAILURES=NUM_FAILURES+1)) rm -f $i else log_note "Test of $FILEBASE passed" fi done if [ $NUM_FAILURES -gt 0 ]; then log_fail "Saw $NUM_FAILURES failures" else log_note "Number of failures: $NUM_FAILURES" log_pass fi else log_unsupported "No tests queued, no SMP-capable devices found" fi