1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)hotspare_onoffline_004_neg.ksh 1.5 09/06/22 SMI" 30# 31. $STF_SUITE/tests/hotspare/hotspare.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: hotspare_onoffline_004_neg 38# 39# DESCRIPTION: 40# If a hot spare has been activated, 41# turning that basic vdev offline and back online during I/O completes. 42# Make sure the integrity of the file system and the resilvering. 43# 44# STRATEGY: 45# 1. Create a storage pool with hot spares 46# 2. Activate the hot spare 47# 3. Start some random I/O 48# 4. Try 'zpool offline' & 'zpool online' with the basic vdev 49# 5. Verify the integrity of the file system and the resilvering. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING STATUS: COMPLETED (2006-06-07) 56# 57# __stc_assertion_end 58# 59############################################################################### 60 61verify_runnable "global" 62 63function cleanup 64{ 65 kill_all_wp 66 poolexists $TESTPOOL && \ 67 destroy_pool $TESTPOOL 68 69 [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 70 71 partition_cleanup 72} 73 74function kill_all_wp 75{ 76 for wait_pid in $child_pids 77 do 78 $KILL $wait_pid 79 $WAIT $wait_pid 80 done 81} 82 83function start_all_wp 84{ 85 typeset -i i=0 86 typeset -i iters=1 87 88 child_pids="" 89 while (( i < iters )); do 90 log_note "Invoking $FILE_TRUNC with: $options_display" 91 $FILE_TRUNC $options $TESTDIR/$TESTFILE.$i & 92 typeset pid=$! 93 94 child_pids="$child_pids $pid" 95 ((i = i + 1)) 96 done 97} 98 99function verify_assertion # dev 100{ 101 typeset dev=$1 102 typeset -i i=0 103 typeset -i iters=1 104 typeset odev=${pooldevs[0]} 105 106 log_must $ZPOOL replace $TESTPOOL $odev $dev 107 108 i=0 109 while (( i < iters )); do 110 start_all_wp 111 while true; do 112 if is_pool_resilvered "$TESTPOOL"; then 113 [ -s "$TESTDIR/$TESTFILE.$i" ] && break 114 fi 115 $SLEEP 2 116 done 117 118 kill_all_wp 119 log_must test -s $TESTDIR/$TESTFILE.$i 120 121 log_must $ZPOOL offline $TESTPOOL $odev 122 log_must check_state $TESTPOOL $odev "offline" 123 124 log_must $ZPOOL online $TESTPOOL $odev 125 log_must check_state $TESTPOOL $odev "online" 126 (( i = i + 1 )) 127 done 128 129 log_must $ZPOOL detach $TESTPOOL $dev 130} 131 132log_assert "'zpool offline/online <pool> <vdev>' against a spared basic vdev during I/O completes." 133 134log_onexit cleanup 135 136set_devs 137 138options="" 139options_display="default options" 140 141[[ -n "$HOLES_FILESIZE" ]] && options=" $options -f $HOLES_FILESIZE " 142 143[[ -n "$HOLES_BLKSIZE" ]] && options="$options -b $HOLES_BLKSIZE " 144 145[[ -n "$HOLES_COUNT" ]] && options="$options -c $HOLES_COUNT " 146 147[[ -n "$HOLES_SEED" ]] && options="$options -s $HOLES_SEED " 148 149[[ -n "$HOLES_FILEOFFSET" ]] && options="$options -o $HOLES_FILEOFFSET " 150 151options="$options -r" 152 153[[ -n "$options" ]] && options_display=$options 154 155typeset child_pid="" 156 157for keyword in "${keywords[@]}" ; do 158 setup_hotspares "$keyword" 159 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL 160 161 iterate_over_hotspares verify_assertion 162 163 verify_filesys "$TESTPOOL" "$TESTPOOL" "$HOTSPARE_TMPDIR" 164 destroy_pool "$TESTPOOL" 165done 166 167log_pass "'zpool offline/online <pool> <vdev>' against a spared basic vdev during I/O completes." 168