]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
1 | #!/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 2008 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | # | |
27 | ||
28 | # | |
c1d9abf9 | 29 | # Copyright (c) 2012, 2016 by Delphix. All rights reserved. |
6bb24f4d BB |
30 | # |
31 | ||
32 | . $STF_SUITE/include/libtest.shlib | |
33 | . $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib | |
34 | ||
35 | # | |
36 | # DESCRIPTION: | |
37 | # 'zpool create' will fail in the following cases: | |
38 | # existent pool; device is part of an active pool; nested virtual devices; | |
39 | # differently sized devices without -f option; device being currently | |
40 | # mounted; devices in /etc/vfstab; specified as the dedicated dump device. | |
41 | # | |
42 | # STRATEGY: | |
43 | # 1. Create case scenarios | |
44 | # 2. For each scenario, try to create a new pool with the virtual devices | |
45 | # 3. Verify the creation is failed. | |
46 | # | |
47 | ||
48 | verify_runnable "global" | |
49 | ||
50 | function cleanup | |
51 | { | |
8c54ddd3 BB |
52 | for pool in $TESTPOOL $TESTPOOL1 |
53 | do | |
54 | destroy_pool $pool | |
55 | done | |
6bb24f4d BB |
56 | |
57 | if [[ -n $saved_dump_dev ]]; then | |
7839c4b5 MM |
58 | if is_freebsd; then |
59 | log_must dumpon $saved_dump_dev | |
60 | else | |
61 | log_must dumpadm -u -d $saved_dump_dev | |
62 | fi | |
6bb24f4d BB |
63 | fi |
64 | ||
8c54ddd3 | 65 | partition_disk $SIZE $disk 7 |
6bb24f4d BB |
66 | } |
67 | ||
68 | log_assert "'zpool create' should be failed with inapplicable scenarios." | |
69 | log_onexit cleanup | |
70 | ||
71 | if [[ -n $DISK ]]; then | |
8c54ddd3 | 72 | disk=$DISK |
6bb24f4d | 73 | else |
8c54ddd3 | 74 | disk=$DISK0 |
6bb24f4d BB |
75 | fi |
76 | pooldev1=${disk}${SLICE_PREFIX}${SLICE0} | |
77 | pooldev2=${disk}${SLICE_PREFIX}${SLICE1} | |
78 | mirror1="${disk}${SLICE_PREFIX}${SLICE1} ${disk}${SLICE_PREFIX}${SLICE3}" | |
79 | mirror2="${disk}${SLICE_PREFIX}${SLICE4} ${disk}${SLICE_PREFIX}${SLICE5}" | |
80 | raidz1=$mirror1 | |
81 | raidz2=$mirror2 | |
82 | diff_size_dev="${disk}${SLICE_PREFIX}${SLICE6} ${disk}${SLICE_PREFIX}${SLICE7}" | |
83 | vfstab_dev=$(find_vfstab_dev) | |
6bb24f4d | 84 | |
8c54ddd3 BB |
85 | if is_linux; then |
86 | partition_disk $SIZE $disk 7 | |
87 | cyl=$(get_endslice $disk $SLICE5) | |
cf8738d8 | 88 | log_must set_partition $SLICE6 "$cyl" $SIZE1 $disk |
8c54ddd3 BB |
89 | else |
90 | specified_dump_dev=${disk}${SLICE_PREFIX}${SLICE0} | |
91 | saved_dump_dev=$(save_dump_dev) | |
92 | ||
93 | cyl=$(get_endslice $disk $SLICE6) | |
cf8738d8 | 94 | log_must set_partition $SLICE7 "$cyl" $SIZE1 $disk |
8c54ddd3 | 95 | fi |
6bb24f4d BB |
96 | create_pool "$TESTPOOL" "$pooldev1" |
97 | ||
98 | # | |
99 | # Set up the testing scenarios parameters | |
100 | # | |
101 | set -A arg "$TESTPOOL $pooldev2" \ | |
8c54ddd3 BB |
102 | "$TESTPOOL1 $pooldev1" \ |
103 | "$TESTPOOL1 $TESTDIR0/$FILEDISK0" \ | |
104 | "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \ | |
105 | "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \ | |
106 | "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \ | |
107 | "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \ | |
108 | "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \ | |
109 | "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \ | |
110 | "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \ | |
111 | "$TESTPOOL1 mirror $diff_size_dev" \ | |
112 | "$TESTPOOL1 raidz $diff_size_dev" \ | |
113 | "$TESTPOOL1 raidz1 $diff_size_dev" \ | |
6bb24f4d | 114 | "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \ |
8c54ddd3 BB |
115 | "$TESTPOOL1 $vfstab_dev" \ |
116 | "$TESTPOOL1 ${disk}s10" \ | |
6bb24f4d BB |
117 | "$TESTPOOL1 spare $pooldev2" |
118 | ||
2171eb71 | 119 | unset NOINUSE_CHECK |
6bb24f4d BB |
120 | typeset -i i=0 |
121 | while (( i < ${#arg[*]} )); do | |
8c54ddd3 BB |
122 | log_mustnot zpool create ${arg[i]} |
123 | (( i = i+1 )) | |
6bb24f4d BB |
124 | done |
125 | ||
126 | # now destroy the pool to be polite | |
c1d9abf9 | 127 | log_must zpool destroy -f $TESTPOOL |
6bb24f4d | 128 | |
8c54ddd3 BB |
129 | if ! is_linux; then |
130 | # create/destroy a pool as a simple way to set the partitioning | |
131 | # back to something normal so we can use this $disk as a dump device | |
132 | log_must zpool create -f $TESTPOOL3 $disk | |
133 | log_must zpool destroy -f $TESTPOOL3 | |
6bb24f4d | 134 | |
7839c4b5 MM |
135 | if is_freebsd; then |
136 | log_must dumpon ${DEV_DSKDIR}/$specified_dump_dev | |
137 | else | |
138 | log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev | |
139 | fi | |
8c54ddd3 | 140 | log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev" |
6bb24f4d | 141 | |
8c54ddd3 BB |
142 | # Also check to see that in-use checking prevents us from creating |
143 | # a zpool from just the first slice on the disk. | |
144 | log_mustnot zpool create \ | |
145 | -f $TESTPOOL1 ${specified_dump_dev}${SLICE_PREFIX}${SLICE0} | |
146 | fi | |
6bb24f4d BB |
147 | |
148 | log_pass "'zpool create' is failed as expected with inapplicable scenarios." |