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 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 48verify_runnable "global" 49 50function cleanup 51{ 52 for pool in $TESTPOOL $TESTPOOL1 53 do 54 destroy_pool $pool 55 done 56 57 if [[ -n $saved_dump_dev ]]; then 58 log_must $DUMPADM -u -d $saved_dump_dev 59 fi 60 61 partition_disk $SIZE $disk 6 62} 63 64log_assert "'zpool create' should be failed with inapplicable scenarios." 65log_onexit cleanup 66 67if [[ -n $DISK ]]; then 68 disk=$DISK 69else 70 disk=$DISK0 71fi 72pooldev1=${disk}s${SLICE0} 73pooldev2=${disk}s${SLICE1} 74mirror1="${disk}s${SLICE1} ${disk}s${SLICE3}" 75mirror2="${disk}s${SLICE4} ${disk}s${SLICE5}" 76raidz1=$mirror1 77raidz2=$mirror2 78diff_size_dev="${disk}s${SLICE6} ${disk}s${SLICE7}" 79vfstab_dev=$(find_vfstab_dev) 80specified_dump_dev=${disk}s${SLICE0} 81saved_dump_dev=$(save_dump_dev) 82 83cyl=$(get_endslice $disk $SLICE6) 84set_partition $SLICE7 "$cyl" $SIZE1 $disk 85create_pool "$TESTPOOL" "$pooldev1" 86 87# 88# Set up the testing scenarios parameters 89# 90set -A arg "$TESTPOOL $pooldev2" \ 91 "$TESTPOOL1 $pooldev1" \ 92 "$TESTPOOL1 $TESTDIR0/$FILEDISK0" \ 93 "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \ 94 "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \ 95 "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \ 96 "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \ 97 "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \ 98 "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \ 99 "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \ 100 "$TESTPOOL1 mirror $diff_size_dev" \ 101 "$TESTPOOL1 raidz $diff_size_dev" \ 102 "$TESTPOOL1 raidz1 $diff_size_dev" \ 103 "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \ 104 "$TESTPOOL1 $vfstab_dev" \ 105 "$TESTPOOL1 ${disk}s10" \ 106 "$TESTPOOL1 spare $pooldev2" 107 108typeset -i i=0 109while (( i < ${#arg[*]} )); do 110 log_mustnot $ZPOOL create ${arg[i]} 111 (( i = i+1 )) 112done 113 114# now destroy the pool to be polite 115log_must $ZPOOL destroy -f $TESTPOOL 116 117# create/destroy a pool as a simple way to set the partitioning 118# back to something normal so we can use this $disk as a dump device 119log_must $ZPOOL create -f $TESTPOOL3 $disk 120log_must $ZPOOL destroy -f $TESTPOOL3 121 122log_must $DUMPADM -d /dev/dsk/$specified_dump_dev 123log_mustnot $ZPOOL create -f $TESTPOOL1 "$specified_dump_dev" 124 125# Also check to see that in-use checking prevents us from creating 126# a zpool from just the first slice on the disk. 127log_mustnot $ZPOOL create -f $TESTPOOL1 ${specified_dump_dev}s0 128 129log_pass "'zpool create' is failed as expected with inapplicable scenarios." 130