1#!/usr/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2013 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/online_offline/online_offline.cfg 34 35# 36# DESCRIPTION: 37# Turning both disks offline should fail. 38# 39# STRATEGY: 40# 1. Create a multidisk stripe and start some random I/O 41# 2. For two disks in the stripe, set them offline sequentially. 42# 3. Zpool offline should fail in both cases. 43# 4. Verify the integrity of the file system and the resilvering. 44# 45 46verify_runnable "global" 47 48DISKLIST=$(get_disklist $TESTPOOL) 49 50function cleanup 51{ 52 if [[ -n "$child_pids" ]]; then 53 for wait_pid in $child_pids 54 do 55 $KILL $wait_pid 56 done 57 fi 58 59 if poolexists $TESTPOOL1; then 60 destroy_pool $TESTPOOL1 61 fi 62 63 [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 64} 65 66log_assert "Turning a disk offline and back online during I/O completes." 67 68options="" 69options_display="default options" 70 71log_onexit cleanup 72 73[[ -n "$HOLES_FILESIZE" ]] && options=" $options -f $HOLES_FILESIZE " 74 75[[ -n "$HOLES_BLKSIZE" ]] && options="$options -b $HOLES_BLKSIZE " 76 77[[ -n "$HOLES_COUNT" ]] && options="$options -c $HOLES_COUNT " 78 79[[ -n "$HOLES_SEED" ]] && options="$options -s $HOLES_SEED " 80 81[[ -n "$HOLES_FILEOFFSET" ]] && options="$options -o $HOLES_FILEOFFSET " 82 83options="$options -r " 84 85[[ -n "$options" ]] && options_display=$options 86 87child_pid="" 88 89typeset -i iters=2 90typeset -i index=0 91 92specials_list="" 93i=0 94while [[ $i != 3 ]]; do 95 $MKFILE 100m $TESTDIR/$TESTFILE1.$i 96 specials_list="$specials_list $TESTDIR/$TESTFILE1.$i" 97 98 ((i = i + 1)) 99done 100 101create_pool $TESTPOOL1 $specials_list 102log_must $ZFS create $TESTPOOL1/$TESTFS1 103log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1 104 105i=0 106while [[ $i -lt $iters ]]; do 107 log_note "Invoking $FILE_TRUNC with: $options_display" 108 $FILE_TRUNC $options $TESTDIR/$TESTFILE.$i & 109 typeset pid=$! 110 111 $SLEEP 1 112 if ! $PS -p $pid > /dev/null 2>&1; then 113 log_fail "$FILE_TRUNC $options $TESTDIR/$TESTFILE.$i" 114 fi 115 116 child_pids="$child_pids $pid" 117 ((i = i + 1)) 118done 119 120set -A disk "" $specials_list 121 122log_mustnot $ZPOOL offline $TESTPOOL1 ${disk[1]} 123log_mustnot $ZPOOL offline $TESTPOOL1 ${disk[2]} 124 125$SLEEP 60 126 127for wait_pid in $child_pids 128do 129 $KILL $wait_pid 130done 131child_pids="" 132 133log_pass 134