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 log_must zpool wait -t resilver $TESTPOOL
94 log_must zpool clear $TESTPOOL
95 while [[ $j -lt ${#disks[*]} ]]; do
96 if [[ $j -eq $i ]]; then
100 log_must zpool offline $TESTPOOL ${disks[$j]}
101 check_state $TESTPOOL ${disks[$j]} "offline" || \
102 log_fail "Failed to set ${disks[$j]} offline"
105 elif [[ $pooltype = 'raidz' ]]; then
106 # Hold one disk offline, verify the others can't be offlined.
107 log_must zpool offline $TESTPOOL ${disks[$i]}
108 check_state $TESTPOOL ${disks[$i]} "offline" || \
109 log_fail "Failed to set ${disks[$i]} offline"
110 while [[ $j -lt ${#disks[*]} ]]; do
111 if [[ $j -eq $i ]]; then
115 log_mustnot zpool offline $TESTPOOL ${disks[$j]}
116 check_state $TESTPOOL ${disks[$j]} "online" || \
117 log_fail "Failed to set ${disks[$j]} online"
118 check_state $TESTPOOL ${disks[$i]} "offline" || \
119 log_fail "Failed to set ${disks[$i]} offline"
122 log_must zpool online $TESTPOOL ${disks[$i]}
123 check_state $TESTPOOL ${disks[$i]} "online" || \
124 log_fail "Failed to set ${disks[$i]} online"
125 log_must zpool wait -t resilver $TESTPOOL
126 log_must zpool clear $TESTPOOL
131 log_must kill $killpid
134 typeset dir=$(get_device_dir $DISKS)
135 verify_filesys "$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir"