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) 2012 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_create
/zpool_create.shlib
37 # 'zpool create' have to use '-f' scenarios
40 # 1. Prepare the scenarios
41 # 2. Create pool without '-f' and verify it fails
42 # 3. Create pool with '-f' and verify it succeeds
45 verify_runnable
"global"
49 if [[ $exported_pool == true
]]; then
50 if [[ $force_pool == true
]]; then
51 log_must
$ZPOOL create \
52 -f $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0}
54 log_must
$ZPOOL import
$TESTPOOL
58 if poolexists
$TESTPOOL ; then
59 destroy_pool
$TESTPOOL
62 if poolexists
$TESTPOOL1 ; then
63 destroy_pool
$TESTPOOL1
67 # recover it back to EFI label
69 create_pool
$TESTPOOL $disk
70 destroy_pool
$TESTPOOL
72 partition_disk
$SIZE $disk 6
76 # create overlap slice 0 and 1 on $disk
78 function create_overlap_slice
80 typeset format_file
=/var
/tmp
/format_overlap.$$
83 $ECHO "partition" >$format_file
84 $ECHO "0" >> $format_file
85 $ECHO "" >> $format_file
86 $ECHO "" >> $format_file
87 $ECHO "0" >> $format_file
88 $ECHO "200m" >> $format_file
89 $ECHO "1" >> $format_file
90 $ECHO "" >> $format_file
91 $ECHO "" >> $format_file
92 $ECHO "0" >> $format_file
93 $ECHO "400m" >> $format_file
94 $ECHO "label" >> $format_file
95 $ECHO "" >> $format_file
96 $ECHO "q" >> $format_file
97 $ECHO "q" >> $format_file
99 $FORMAT -e -s -d $disk -f $format_file
103 if (( ret
!= 0 )); then
104 log_fail
"unable to create overlap slice."
110 log_assert
"'zpool create' have to use '-f' scenarios"
113 typeset exported_pool
=false
114 typeset force_pool
=false
116 if [[ -n $DISK ]]; then
122 # overlapped slices as vdev need -f to create pool
124 # Make the disk is EFI labeled first via pool creation
125 create_pool
$TESTPOOL $disk
126 destroy_pool
$TESTPOOL
128 # Make the disk is VTOC labeled since only VTOC label supports overlap
129 log_must labelvtoc
$disk
130 log_must create_overlap_slice
$disk
132 log_mustnot
$ZPOOL create
$TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0}
133 log_must
$ZPOOL create
-f $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0}
134 destroy_pool
$TESTPOOL
136 # exported device to be as spare vdev need -f to create pool
138 log_must
$ZPOOL create
-f $TESTPOOL $disk
139 destroy_pool
$TESTPOOL
140 log_must partition_disk
$SIZE $disk 6
141 create_pool
$TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} \
142 ${disk}${SLICE_PREFIX}${SLICE1}
143 log_must
$ZPOOL export $TESTPOOL
145 log_mustnot
$ZPOOL create
$TESTPOOL1 ${disk}${SLICE_PREFIX}${SLICE3} \
146 spare
${disk}${SLICE_PREFIX}${SLICE1}
147 create_pool
$TESTPOOL1 ${disk}${SLICE_PREFIX}${SLICE3} \
148 spare
${disk}${SLICE_PREFIX}${SLICE1}
150 destroy_pool
$TESTPOOL1
152 log_pass
"'zpool create' have to use '-f' scenarios"