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 2009 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 a disk offline and back online during I/O completes. 38 # 39 # STRATEGY: 40 # 1. Create a mirror and start some random I/O 41 # 2. For each disk in the mirror, set it offline and online 42 # 3. Verify the integrity of the file system and the resilvering. 43 # 44 45 verify_runnable "global" 46 47 DISKLIST=$(get_disklist $TESTPOOL) 48 49 function cleanup 50 { 51 # 52 # Ensure we don't leave disks in the offline state 53 # 54 for disk in $DISKLIST; do 55 log_must $ZPOOL online $TESTPOOL $disk 56 check_state $TESTPOOL $disk "online" 57 if [[ $? != 0 ]]; then 58 log_fail "Unable to online $disk" 59 fi 60 61 done 62 63 [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 64 } 65 66 log_assert "Turning a disk offline and back online during I/O completes." 67 68 options="" 69 options_display="default options" 70 71 log_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 83 options="$options -r " 84 85 [[ -n "$options" ]] && options_display=$options 86 87 typeset child_pid="" 88 89 typeset -i iters=2 90 typeset -i index=0 91 92 i=0 93 while [[ $i -lt $iters ]]; do 94 log_note "Invoking $FILE_TRUNC with: $options_display" 95 $FILE_TRUNC $options $TESTDIR/$TESTFILE.$i & 96 typeset pid=$! 97 98 $SLEEP 1 99 if ! $PS -p $pid > /dev/null 2>&1; then 100 log_fail "$FILE_TRUNC $options $TESTDIR/$TESTFILE.$i" 101 fi 102 103 child_pids="$child_pids $pid" 104 ((i = i + 1)) 105 done 106 107 for disk in $DISKLIST; do 108 # 109 # Allow some common data to reach each side of the mirror. 110 # 111 $SLEEP 30 112 113 i=0 114 while [[ $i -lt $iters ]]; do 115 log_must $ZPOOL offline $TESTPOOL $disk 116 check_state $TESTPOOL $disk "offline" 117 if [[ $? != 0 ]]; then 118 log_fail "$disk of $TESTPOOL is not offline." 119 fi 120 121 (( i = i + 1 )) 122 done 123 124 # 125 # Sleep to allow the two sides to get out of sync 126 # 127 $SLEEP 60 128 129 log_must $ZPOOL online $TESTPOOL $disk 130 check_state $TESTPOOL $disk "online" 131 if [[ $? != 0 ]]; then 132 log_fail "$disk of $TESTPOOL did not match online state" 133 fi 134 done 135 136 for wait_pid in $child_pids 137 do 138 $KILL $wait_pid 139 done 140 141 typeset dir=$(get_device_dir $DISKS) 142 verify_filesys "$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir" 143 144 log_pass