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) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
36 # Test force faulting a VDEV with 'zpool offline -f'
39 # For both temporary and persistent faults, do the following:
40 # 1. Force fault a vdev, and clear the fault.
41 # 2. Offline a vdev, force fault it, clear the fault, and online it.
42 # 3. Force fault a vdev, export it, then import it.
44 verify_runnable "global"
46 DISKLIST=$(get_disklist $TESTPOOL)
47 set -A disks $DISKLIST
48 typeset -i num=${#disks[*]}
54 # Ensure we don't leave disks in the offline state
55 for disk in $DISKLIST; do
56 log_must zpool online $TESTPOOL $disk
57 check_state $TESTPOOL $disk "online"
58 if [[ $? != 0 ]]; then
59 log_fail "Unable to online $disk"
64 log_assert "Executing 'zpool offline -f' with correct options succeeds"
68 if [[ -z $DISKLIST ]]; then
69 log_fail "DISKLIST is empty."
75 # Get name of the first disk in the pool
78 # Test temporary and persistent faults
80 # Force fault disk, and clear the fault
81 log_must zpool offline -$arg $TESTPOOL $disk
82 check_state $TESTPOOL $disk "faulted"
83 log_must zpool clear $TESTPOOL $disk
84 check_state $TESTPOOL $disk "online"
86 # Offline a disk, force fault it, clear the fault, and online it
87 log_must zpool offline $TESTPOOL $disk
88 check_state $TESTPOOL $disk "offline"
89 log_must zpool offline -$arg $TESTPOOL $disk
90 check_state $TESTPOOL $disk "faulted"
91 log_must zpool clear $TESTPOOL $disk
92 check_state $TESTPOOL $disk "offline"
93 log_must zpool online $TESTPOOL $disk
94 check_state $TESTPOOL $disk "online"
96 # Test faults across imports
97 log_must zpool offline -tf $TESTPOOL $disk
98 check_state $TESTPOOL $disk "faulted"
99 log_must zpool export $TESTPOOL
100 log_must zpool import $TESTPOOL
101 log_note "-$arg now imported"
102 if [[ "$arg" = "f" ]] ; then
104 check_state $TESTPOOL $disk "faulted"
105 log_must zpool clear $TESTPOOL $disk
107 # Temporary faults get cleared by imports
108 check_state $TESTPOOL $disk "online"
111 log_pass "'zpool offline -f' with correct options succeeded"