Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_001_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_001_neg.ksh (revision 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_001_neg.ksh (revision 292292) @@ -1,112 +1,109 @@ #!/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 2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_007_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib . $STF_SUITE/include/libsas.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_autoreplace_001_neg # # DESCRIPTION: # In a pool with the autoreplace property unset, a vdev will not be # replaced by physical path # # STRATEGY: # 1. Create 1 storage pool without hot spares # 2. Remove a vdev by disabling its SAS phy # 3. Export the pool # 4. Reenable the missing dev's SAS phy # 5. Erase the missing dev's ZFS label # 6. Disable the missing dev's SAS phy again # 7. Import the pool # 8. Reenable the missing dev's SAS phy # 9. Verify that it does not get added to the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2013-02-4) # # __stc_assertion_end # ############################################################################### verify_runnable "global" verify_disk_count "$DISKS" 5 function cleanup { poolexists $TESTPOOL && \ destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$REMOVAL_DISK" ]; then - camcontrol inquiry $REMOVAL_DISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup } log_assert "A pool with the autoreplace property set will replace disks by physical path" log_onexit cleanup function verify_assertion { do_autoreplace # 9. Verify that it does not get added to the pool for ((timeout=0; timeout<4; timeout=$timeout+1)); do log_mustnot check_state $TESTPOOL $REMOVAL_DISK "ONLINE" $SLEEP 5 done } typeset REMOVAL_DISK=$DISK0 typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" for keyword in "${MY_KEYWORDS[@]}" ; do log_must create_pool $TESTPOOL $keyword $POOLDEVS log_must poolexists "$TESTPOOL" log_must $ZPOOL set autoreplace=off $TESTPOOL verify_assertion destroy_pool "$TESTPOOL" done Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_002_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_002_pos.ksh (revision 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_002_pos.ksh (revision 292292) @@ -1,115 +1,112 @@ #!/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 2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_007_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib . $STF_SUITE/include/libsas.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_autoreplace_002_pos # # DESCRIPTION: # In a pool with the autoreplace property set, a vdev will be # replaced by physical path # # STRATEGY: # 1. Create 1 storage pool without hot spares # 2. Remove a vdev by disabling its SAS phy # 3. Export the pool # 4. Reenable the missing dev's SAS phy # 5. Erase the missing dev's ZFS label # 6. Disable the missing dev's SAS phy again # 7. Import the pool # 8. Reenable the missing dev's SAS phy # 9. Verify that it does get added to the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2013-02-4) # # __stc_assertion_end # ############################################################################### verify_runnable "global" verify_disk_count "$DISKS" 5 function cleanup { poolexists $TESTPOOL && \ destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$REMOVAL_DISK" ]; then - camcontrol inquiry $REMOVAL_DISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup } log_assert "A pool with the autoreplace property will replace disks by physical path" log_onexit cleanup function verify_assertion { do_autoreplace # 9. Verify that it gets added to the pool for ((timeout=0; $timeout<10; timeout=$timeout+1)); do if check_state $TESTPOOL $REMOVAL_DISK "ONLINE"; then break fi $SLEEP 6 done log_must check_state $TESTPOOL "$REMOVAL_DISK" "ONLINE" } typeset REMOVAL_DISK=$DISK0 typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" for keyword in "${MY_KEYWORDS[@]}" ; do log_must create_pool $TESTPOOL $keyword $POOLDEVS log_must poolexists "$TESTPOOL" log_must $ZPOOL set autoreplace=on $TESTPOOL verify_assertion destroy_pool "$TESTPOOL" done Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh (revision 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh (revision 292292) @@ -1,124 +1,121 @@ #!/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 2014 Spectra Logic. All rights reserved. # Use is subject to license terms. # # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib . $STF_SUITE/include/libsas.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_autoreplace_003_pos # # DESCRIPTION: # In a pool with the autoreplace property set, a vdev will be # replaced by physical path even if a spare is already active for that # vdev # # STRATEGY: # 1. Create 1 storage pool with a hot spare # 2. Remove a vdev by disabling its SAS phy # 3. Wait for the hotspare to fully resilver # 4. Export the pool # 5. Reenable the missing dev's SAS phy # 6. Erase the missing dev's ZFS label # 7. Disable the missing dev's SAS phy again # 8. Import the pool # 9. Reenable the missing dev's SAS phy # 10. Verify that it does get added to the pool. # 11. Verify that the hotspare gets removed. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2013-05-13) # # __stc_assertion_end # ############################################################################### verify_runnable "global" verify_disk_count "$DISKS" 5 function cleanup { poolexists $TESTPOOL && \ destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$REMOVAL_DISK" ]; then - camcontrol inquiry $REMOVAL_DISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup } log_assert "A pool with the autoreplace property will replace disks by physical path" log_onexit cleanup function verify_assertion { do_autoreplace "$SPARE_DISK" # Verify that the original disk gets added to the pool for ((timeout=0; $timeout<10; timeout=$timeout+1)); do if check_state $TESTPOOL $REMOVAL_DISK "ONLINE"; then break fi $SLEEP 6 done log_must check_state $TESTPOOL "$REMOVAL_DISK" "ONLINE" # Wait for resilvering to complete wait_until_resilvered # Check that the spare is deactivated log_must check_state $TESTPOOL "$SPARE_DISK" "AVAIL" } typeset SPARE_DISK=$DISK0 typeset REMOVAL_DISK=$DISK1 typeset POOLDEVS="$DISK1 $DISK2 $DISK3 $DISK4" set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" for keyword in "${MY_KEYWORDS[@]}" ; do log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SPARE_DISK log_must poolexists "$TESTPOOL" log_must $ZPOOL set autoreplace=on $TESTPOOL verify_assertion destroy_pool "$TESTPOOL" done Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh (revision 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh (revision 292292) @@ -1,185 +1,182 @@ #!/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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_006_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/include/libsas.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfs_hotspare_004_pos # # DESCRIPTION: # If a vdev gets removed from a pool with a spare, the spare will be # activated. # # # STRATEGY: # 1. Create 1 storage pools with hot spares. Use disks instead of files # because they can be removed. # 2. Remove one vdev by turning off its SAS phy. # 3. Verify that the spare is in use. # 4. Reinsert the vdev by enabling its phy # 5. Verify that the vdev gets resilvered and the spare gets removed # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2012-08-10) # # __stc_assertion_end # ############################################################################### verify_runnable "global" verify_disk_count "$DISKS" 5 function cleanup { poolexists $TESTPOOL && \ destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$REMOVAL_DISK" ]; then - camcontrol inquiry $REMOVAL_DISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup } log_assert "Removing a disk from a pool results in the spare activating" log_onexit cleanup function verify_assertion # spare_dev { typeset sdev=$1 find_verify_sas_disk $REMOVAL_DISK log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" disable_sas_disk $EXPANDER $PHY #Check to make sure the disk is gone camcontrol inquiry $REMOVAL_DISK > /dev/null 2>&1 if [ $? = 0 ]; then log_fail "Disk \"$REMOVAL_DISK\" was not removed" fi # Check to make sure ZFS sees the disk as removed for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" is_removed=$? if [[ $is_removed == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" # Check that the spare was activated for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$sdev" "INUSE" spare_inuse=$? if [[ $spare_inuse == 0 ]]; then break fi $SLEEP 3 done log_must $ZPOOL status $TESTPOOL log_must check_state $TESTPOOL "$sdev" "INUSE" # Reenable the missing disk log_note "Reenabling phy on expander $EXPANDER phy $PHY" enable_sas_disk $EXPANDER $PHY # Check that the disk has returned for ((timeout=0; $timeout<20; timeout=$timeout+1)); do find_disk_by_phy $EXPANDER $PHY if [[ -n "$FOUNDDISK" ]]; then break fi $SLEEP 3 done if [[ -z "$FOUNDDISK" ]]; then log_fail "Disk $REMOVAL_DISK never reappeared" fi #Check that the disk has rejoined the pool for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL $REMOVAL_DISK ONLINE rejoined=$? if [[ $rejoined == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL $REMOVAL_DISK ONLINE #Check that the pool resilvered while ! is_pool_resilvered $TESTPOOL; do $SLEEP 2 done log_must is_pool_resilvered $TESTPOOL log_must $ZPOOL status #Finally, check that the spare deactivated for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$sdev" "AVAIL" deactivated=$? if [[ $deactivated == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL "$sdev" "AVAIL" } typeset REMOVAL_DISK=$DISK0 typeset SDEV=$DISK4 typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" for keyword in "${MY_KEYWORDS[@]}" ; do log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SDEV log_must poolexists "$TESTPOOL" log_must $ZPOOL set autoreplace=on "$TESTPOOL" iterate_over_hotspares verify_assertion $SDEV destroy_pool "$TESTPOOL" done Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh (revision 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh (revision 292292) @@ -1,159 +1,156 @@ #!/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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_006_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/include/libsas.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfs_hotspare_007_pos # # DESCRIPTION: # If a vdev gets removed from a pool with a spare while zfsd is shut # down, then the spare will be activated when zfsd restarts # # # STRATEGY: # 1. Create 1 storage pools with hot spares. Use disks instead of files # because they can be removed. # 2. Turn off zfsd # 3. Remove one vdev by turning off its SAS phy. # 4. Restart zfsd # 5. Verify that the spare is in use. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2014-09-17) # # __stc_assertion_end # ############################################################################### verify_runnable "global" verify_disk_count "$DISKS" 5 function cleanup { poolexists $TESTPOOL && \ destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$REMOVAL_DISK" ]; then - camcontrol inquiry $REMOVAL_DISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup } log_assert "zfsd will spare missing drives on startup" log_onexit cleanup function verify_assertion # spare_dev { typeset sdev=$1 find_verify_sas_disk $REMOVAL_DISK stop_zfsd log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" disable_sas_disk $EXPANDER $PHY #Check to make sure the disk is gone camcontrol inquiry $REMOVAL_DISK > /dev/null 2>&1 if [ $? = 0 ]; then log_fail "Disk \"$REMOVAL_DISK\" was not removed" fi # Check to make sure ZFS sees the disk as removed for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" is_removed=$? if [[ $is_removed == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" restart_zfsd # Check that the spare was activated for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$sdev" "INUSE" spare_inuse=$? if [[ $spare_inuse == 0 ]]; then break fi $SLEEP 3 done log_must $ZPOOL status $TESTPOOL log_must check_state $TESTPOOL "$sdev" "INUSE" # Reenable the missing disk log_note "Reenabling phy on expander $EXPANDER phy $PHY" enable_sas_disk $EXPANDER $PHY # Check that the disk has returned for ((timeout=0; $timeout<20; timeout=$timeout+1)); do find_disk_by_phy $EXPANDER $PHY if [[ -n "$FOUNDDISK" ]]; then break fi $SLEEP 3 done if [[ -z "$FOUNDDISK" ]]; then log_fail "Disk $REMOVAL_DISK never reappeared" fi } typeset REMOVAL_DISK=$DISK0 typeset SDEV=$DISK4 typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" for keyword in "${MY_KEYWORDS[@]}" ; do log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SDEV log_must poolexists "$TESTPOOL" iterate_over_hotspares verify_assertion $SDEV destroy_pool "$TESTPOOL" done Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh (revision 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh (revision 292292) @@ -1,226 +1,223 @@ #!/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 2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)zfsd_zfsd_002_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/include/libsas.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_import_001_pos # # DESCRIPTION: # If a removed drive gets reinserted while the pool is exported, it will # replace its spare when reinserted. # # This also applies to drives that get reinserted while the machine is # powered off. # # # STRATEGY: # 1. Create 1 storage pools with hot spares. Use disks instead of files # because they can be removed. # 2. Remove one disk by turning off its SAS phy. # 3. Verify that the spare is in use. # 4. Reinsert the vdev by enabling its phy # 5. Verify that the vdev gets resilvered and the spare gets removed # 6. Use additional zpool history data to verify that the pool # finished resilvering _before_ zfsd detached the spare. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2012-08-10) # # __stc_assertion_end # ############################################################################### verify_runnable "global" function cleanup { # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$REMOVAL_DISK" ]; then - camcontrol inquiry $REMOVAL_DISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* poolexists "$TESTPOOL" && \ destroy_pool "$TESTPOOL" partition_cleanup } function verify_assertion # spare_dev { typeset sdev=$1 find_verify_sas_disk $REMOVAL_DISK log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" disable_sas_disk $EXPANDER $PHY #Check to make sure the disk is gone camcontrol inquiry $REMOVAL_DISK > /dev/null 2>&1 if [ $? = 0 ]; then log_fail "Disk \"$REMOVAL_DISK\" was not removed" fi # Check to make sure ZFS sees the disk as removed for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" is_removed=$? if [[ $is_removed == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" # Wait for zfsd to activate the spare for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$sdev" "INUSE" spare_inuse=$? if [[ $spare_inuse == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL "$sdev" "INUSE" # Export the pool log_must $ZPOOL export $TESTPOOL # Reenable the missing disk log_note "Reenabling phy on expander $EXPANDER phy $PHY" enable_sas_disk $EXPANDER $PHY # Check that the disk has returned for ((timeout=0; $timeout<20; timeout=$timeout+1)); do find_disk_by_phy $EXPANDER $PHY if [[ -n "$FOUNDDISK" ]]; then break fi $SLEEP 3 done if [[ -z "$FOUNDDISK" ]]; then log_fail "Disk $REMOVAL_DISK never reappeared" fi # Import the pool log_must $ZPOOL import $TESTPOOL #Check that the disk has rejoined the pool for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL $REMOVAL_DISK ONLINE rejoined=$? if [[ $rejoined == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL $REMOVAL_DISK ONLINE #Check that the pool resilvered while ! is_pool_resilvered $TESTPOOL; do $SLEEP 2 done log_must is_pool_resilvered $TESTPOOL #Finally, check that the spare deactivated for ((timeout=0; $timeout<20; timeout=$timeout+1)); do check_state $TESTPOOL "$sdev" "AVAIL" deactivated=$? if [[ $deactivated == 0 ]]; then break fi $SLEEP 3 done log_must check_state $TESTPOOL "$sdev" "AVAIL" # Verify that the spare was detached after the scrub was complete # Note that resilvers and scrubs are recorded identically in zpool # history $ZPOOL history -i $TESTPOOL | awk ' BEGIN { scrub_txg=0; detach_txg=0 } /scrub done/ { split($6, s, "[:\\]]"); t=s[2]; scrub_txg = scrub_txg > t ? scrub_txg : t } /vdev detach/ { split($6, s, "[:\\]]"); t=s[2]; done_txg = done_txg > t ? done_txg : t } END { print("Scrub completed at txg", scrub_txg); print("Spare detached at txg", detach_txg); exit(detach_txg > scrub_txg) }' if [[ $? -ne 0 ]]; then log_fail "The spare detached before the resilver completed" fi } if ! $(is_physical_device $DISKS) ; then log_unsupported "This directory cannot be run on raw files." fi log_assert "If a removed drive gets reinserted while the pool is exported, it will replace its spare when reinserted." log_onexit cleanup set_devs typeset REMOVAL_DISK=$DISK0 typeset SDEV=$DISK4 typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" for keyword in "${MY_KEYWORDS[@]}" ; do log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SDEV log_must poolexists "$TESTPOOL" iterate_over_hotspares verify_assertion $SDEV destroy_pool "$TESTPOOL" done 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 292291) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh (revision 292292) @@ -1,204 +1,200 @@ #!/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/include/libtest.kshlib . $STF_SUITE/include/libsas.kshlib verify_runnable "global" function cleanup { if [[ -n "$child_pids" ]]; then for wait_pid in $child_pids do $KILL $wait_pid done fi if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi # See if the phy has been disabled, and try to re-enable it if possible. if [ ! -z "$TMPDISK" ]; then - echo "TMPDISK is $TMPDISK" - camcontrol inquiry $TMPDISK > /dev/null - if [ $? != 0 ]; then - if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then - enable_sas_disk $EXPANDER $PHY - fi + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY fi fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* } log_assert "Failing a disk from a SAS expander is recognized by ZFS" log_onexit cleanup child_pids="" function run_io { typeset -i processes=$1 typeset -i mbcount=$2 typeset i=0 while [[ $i -lt $processes ]]; do log_note "Invoking dd if=/dev/zero of=$TESTDIR/$TESTFILE.$i &" dd if=/dev/zero of=$TESTDIR/$TESTFILE.$i bs=1m count=$mbcount & typeset pid=$! $SLEEP 1 if ! $PS -p $pid > /dev/null 2>&1; then log_fail "dd if=/dev/zero $TESTDIR/$TESTFILE.$i" fi child_pids="$child_pids $pid" ((i = i + 1)) done } set -A TMPDISKS $DISKS typeset TMPDISK=${TMPDISKS[0]} TMPDISK=${TMPDISK##*/} 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 $TMPDISK" find_verify_sas_disk $TMPDISK log_note "Disabling \"$TMPDISK\" 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. camcontrol inquiry $TMPDISK > /dev/null 2>&1 if [ $? = 0 ]; then log_fail "Disk \"$TMPDISK\" was not removed" fi # Write out data to make sure we can do I/O after the disk failure # XXX KDM should check the status returned from the dd instances log_note "Running $SAS_IO_PROCESSES dd runs of $SAS_IO_MB_PER_PROC MB" run_io $SAS_IO_PROCESSES $SAS_IO_MB_PER_PROC # Wait for the I/O to complete wait # We waited for the child processes to complete, so they're done. child_pids="" # Check to make sure ZFS sees the disk as removed $ZPOOL status $TESTPOOL |grep $TMPDISK |egrep -q 'REMOVED' if [ $? != 0 ]; then $ZPOOL status $TESTPOOL log_fail "disk $TMPDISK not listed as removed" fi # Make sure that the pool is degraded $ZPOOL status $TESTPOOL |grep "state:" |grep DEGRADED > /dev/null if [ $? != 0 ]; then $ZPOOL status $TESTPOOL log_fail "Pool $TESTPOOL not listed as DEGRADED" fi # 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 find_disk_by_phy $EXPANDER $PHY ((retries=0)) while [ -z "$FOUNDDISK" ] && [ "$retries" -lt 10 ]; do $SLEEP 5 find_disk_by_phy $EXPANDER $PHY done if [ -z "$FOUNDDISK" ]; then camcontrol $EXPANDER log_fail "Disk $TMPDISK has not appeared at phy $PHY on expander $EXPANDER after 50 seconds" else log_note "Disk $TMPDISK is back as $FOUNDDISK" fi log_note "Raid type is $type" #Disk should have auto-joined the zpool. Verify it's status is online. $ZPOOL status |grep $TMPDISK |grep ONLINE > /dev/null if [ $? != 0 ]; then $ZPOOL status $TESTPOOL log_fail "disk $TMPDISK did not automatically join the $TESTPOOL" else log_note "After reinsertion, disk is back in pool and online" fi #Make sure auto resilver has begun ((retries=5)) $ZPOOL status $TESTPOOL | egrep "scan:.*(resilver.in.progress|resilvered)" > /dev/null while [ $? != 0 ] && [ "$retries" -gt 0 ]; do log_note "Waiting for autoresilver to start: Retry $retries" $SLEEP 2 ((retries--)) $ZPOOL status $TESTPOOL | egrep "scan:.*(resilver.in.progress|resilvered)" > /dev/null done $ZPOOL status $TESTPOOL | egrep "scan:.*(resilver.in.progress|resilvered)" > /dev/null if [ $? != 0 ]; then $ZPOOL status $TESTPOOL log_fail "Pool $TESTPOOL did not auto-resilver" else log_note "Auto-resilver of disk has started sucessfully." fi #Wait, then verify resilver done, and that pool optimal wait_until_resilvered $ZPOOL status $TESTPOOL destroy_pool $TESTPOOL log_must $RM -rf /$TESTPOOL done log_pass