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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/online_offline
/online_offline.cfg
37 # Turning disks in a pool offline should fail when there is no longer
38 # sufficient redundancy.
41 # 1. Start some random I/O on the mirror or raidz.
42 # 2. Verify that we can offline as many disks as the redundancy level
43 # will support, but not more.
44 # 3. Verify the integrity of the file system and the resilvering.
47 verify_runnable
"global"
49 DISKLIST
=$
(get_disklist
$TESTPOOL)
54 # Ensure we don't leave disks in the offline state
56 for disk
in $DISKLIST; do
57 log_must zpool online
$TESTPOOL $disk
58 check_state
$TESTPOOL $disk "online"
59 if [[ $?
!= 0 ]]; then
60 log_fail
"Unable to online $disk"
65 kill $killpid >/dev
/null
2>&1
66 [[ -e $TESTDIR ]] && log_must
rm -rf $TESTDIR/*
69 log_assert
"Turning both disks offline should fail."
73 file_trunc
-f $
((64 * 1024 * 1024)) -b 8192 -c 0 -r $TESTDIR/$TESTFILE1 &
79 # The setup script will give us either a mirror or a raidz. The former can have
80 # all but one vdev offlined, whereas with raidz there can be only one.
83 zpool list
-v $TESTPOOL |
grep raidz
>/dev
/null
2>&1 && pooltype
='raidz'
86 while [[ $i -lt ${#disks[*]} ]]; do
88 if [[ $pooltype = 'mirror' ]]; then
89 # Hold one disk online, verify the others can be offlined.
90 log_must zpool online
$TESTPOOL ${disks[$i]}
91 check_state
$TESTPOOL ${disks[$i]} "online" || \
92 log_fail
"Failed to set ${disks[$i]} online"
93 # Delay for resilver to complete
94 while ! is_pool_resilvered
$TESTPOOL; do
97 log_must zpool
clear $TESTPOOL
98 while [[ $j -lt ${#disks[*]} ]]; do
99 if [[ $j -eq $i ]]; then
103 log_must zpool offline
$TESTPOOL ${disks[$j]}
104 check_state
$TESTPOOL ${disks[$j]} "offline" || \
105 log_fail
"Failed to set ${disks[$j]} offline"
108 elif [[ $pooltype = 'raidz' ]]; then
109 # Hold one disk offline, verify the others can't be offlined.
110 log_must zpool offline
$TESTPOOL ${disks[$i]}
111 check_state
$TESTPOOL ${disks[$i]} "offline" || \
112 log_fail
"Failed to set ${disks[$i]} offline"
113 while [[ $j -lt ${#disks[*]} ]]; do
114 if [[ $j -eq $i ]]; then
118 log_mustnot zpool offline
$TESTPOOL ${disks[$j]}
119 check_state
$TESTPOOL ${disks[$j]} "online" || \
120 log_fail
"Failed to set ${disks[$j]} online"
121 check_state
$TESTPOOL ${disks[$i]} "offline" || \
122 log_fail
"Failed to set ${disks[$i]} offline"
125 log_must zpool online
$TESTPOOL ${disks[$i]}
126 check_state
$TESTPOOL ${disks[$i]} "online" || \
127 log_fail
"Failed to set ${disks[$i]} online"
128 # Delay for resilver to complete
129 while ! is_pool_resilvered
$TESTPOOL; do
132 log_must zpool
clear $TESTPOOL
137 log_must
kill $killpid
140 typeset dir
=$
(get_device_dir
$DISKS)
141 verify_filesys
"$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir"