]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_011_neg.ksh
Distributed Spare (dRAID) Feature
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_create / zpool_create_011_neg.ksh
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 #
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
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 {
52 for pool in $TESTPOOL $TESTPOOL1
53 do
54 destroy_pool $pool
55 done
56
57 rm -rf $disk1 $disk2 $disk3 $disk4
58
59 if [[ -n $saved_dump_dev ]]; then
60 log_must dumpadm -u -d $saved_dump_dev
61 fi
62 }
63
64 log_assert "'zpool create' should be failed with inapplicable scenarios."
65 log_onexit cleanup
66
67 disk1=$(create_blockfile $FILESIZE)
68 disk2=$(create_blockfile $FILESIZE)
69 disk3=$(create_blockfile $FILESIZE)
70 disk4=$(create_blockfile $FILESIZE1)
71 mirror1="$DISK0 $DISK1"
72 mirror2="$disk1 $disk2"
73 raidz1=$mirror1
74 raidz2=$mirror2
75 draid1="$DISK0 $DISK1 $DISK2"
76 draid2="$disk1 $disk2 $disk3"
77 diff_size_dev="$disk2 $disk4"
78 draid_diff_size_dev="$disk1 $disk2 $disk4"
79 vfstab_dev=$(find_vfstab_dev)
80
81 if is_illumos; then
82 specified_dump_dev=${DISK0}s0
83 saved_dump_dev=$(save_dump_dev)
84
85 cyl=$(get_endslice $DISK0 6)
86 log_must set_partition 7 "$cyl" $SIZE1 $DISK0
87 fi
88 create_pool $TESTPOOL $DISK0
89
90 #
91 # Set up the testing scenarios parameters
92 #
93 set -A arg \
94 "$TESTPOOL1 $DISK0" \
95 "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \
96 "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \
97 "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \
98 "$TESTPOOL1 draid draid $draid draid $draid2" \
99 "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \
100 "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \
101 "$TESTPOOL1 mirror draid $draid1 draid $draid2" \
102 "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \
103 "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \
104 "$TESTPOOL1 draid1 mirror $mirror1 mirror $mirror2" \
105 "$TESTPOOL1 mirror $diff_size_dev" \
106 "$TESTPOOL1 raidz $diff_size_dev" \
107 "$TESTPOOL1 raidz1 $diff_size_dev" \
108 "$TESTPOOL1 draid1 $draid_diff_size_dev" \
109 "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \
110 "$TESTPOOL1 $vfstab_dev" \
111 "$TESTPOOL1 ${DISK0}s10" \
112 "$TESTPOOL1 spare $pooldev2"
113
114 unset NOINUSE_CHECK
115 typeset -i i=0
116 while (( i < ${#arg[*]} )); do
117 log_mustnot zpool create ${arg[i]}
118 (( i = i+1 ))
119 done
120
121 # now destroy the pool to be polite
122 log_must zpool destroy -f $TESTPOOL
123
124 if is_illumos; then
125 # create/destroy a pool as a simple way to set the partitioning
126 # back to something normal so we can use this $disk as a dump device
127 log_must zpool create -f $TESTPOOL3 $DISK1
128 log_must zpool destroy -f $TESTPOOL3
129
130 log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev
131 log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev"
132
133 # Also check to see that in-use checking prevents us from creating
134 # a zpool from just the first slice on the disk.
135 log_mustnot zpool create \
136 -f $TESTPOOL1 ${specified_dump_dev}s0
137 fi
138
139 log_pass "'zpool create' is failed as expected with inapplicable scenarios."