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 2009 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 -f <pool> <vspec> ...' can successfully create a 38# new pool in some cases. 39# 40# STRATEGY: 41# 1. Prepare the scenarios for '-f' option 42# 2. Use -f to override the devices to create new pools 43# 3. Verify the pool created successfully 44# 45 46verify_runnable "global" 47 48function cleanup 49{ 50 for pool in $TESTPOOL $TESTPOOL1 $TESTPOOL2 $TESTPOOL3 $TESTPOOL4 \ 51 $TESTPOOL5 $TESTPOOL6 52 do 53 poolexists $pool && destroy_pool $pool 54 done 55 56 clean_blockfile "$TESTDIR0 $TESTDIR1" 57 58 for file in /var/tmp/$FILEDISK0 /var/tmp/$FILEDISK1 /var/tmp/$FILEDISK2 59 do 60 if [[ -e $file ]]; then 61 rm -rf $file 62 fi 63 done 64 65 partition_disk $SIZE $disk 6 66} 67 68log_onexit cleanup 69 70log_assert "'zpool create -f <pool> <vspec> ...' can successfully create" \ 71 "a new pool in some cases." 72 73if [[ -n $DISK ]]; then 74 disk=$DISK 75else 76 disk=$DISK0 77fi 78create_pool "$TESTPOOL" "${disk}s${SLICE0}" 79log_must echo "y" | newfs /dev/rdsk/${disk}s${SLICE1} >/dev/null 2>&1 80create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}s${SLICE4} 81create_blockfile $FILESIZE1 $TESTDIR1/$FILEDISK1 ${disk}s${SLICE5} 82log_must mkfile $SIZE /var/tmp/$FILEDISK0 83log_must mkfile $SIZE /var/tmp/$FILEDISK1 84log_must mkfile $SIZE /var/tmp/$FILEDISK2 85 86unset NOINUSE_CHECK 87log_must zpool export $TESTPOOL 88log_note "'zpool create' without '-f' will fail " \ 89 "while device is belong to an exported pool." 90log_mustnot zpool create "$TESTPOOL1" "${disk}s${SLICE0}" 91create_pool "$TESTPOOL1" "${disk}s${SLICE0}" 92log_must poolexists $TESTPOOL1 93 94log_note "'zpool create' without '-f' will fail " \ 95 "while device is using by an ufs filesystem." 96log_mustnot zpool create "$TESTPOOL2" "${disk}s${SLICE1}" 97create_pool "$TESTPOOL2" "${disk}s${SLICE1}" 98log_must poolexists $TESTPOOL2 99 100log_note "'zpool create' mirror without '-f' will fail " \ 101 "while devices have different size." 102log_mustnot zpool create "$TESTPOOL3" "mirror" $TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1 103create_pool "$TESTPOOL3" "mirror" $TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1 104log_must poolexists $TESTPOOL3 105 106log_note "'zpool create' mirror without '-f' will fail " \ 107 "while devices are of different types." 108log_mustnot zpool create "$TESTPOOL4" "mirror" /var/tmp/$FILEDISK0 \ 109 ${disk}s${SLICE3} 110create_pool "$TESTPOOL4" "mirror" /var/tmp/$FILEDISK0 ${disk}s${SLICE3} 111log_must poolexists $TESTPOOL4 112 113log_note "'zpool create' without '-f' will fail " \ 114 "while device is part of potentially active pool." 115create_pool "$TESTPOOL5" "mirror" /var/tmp/$FILEDISK1 \ 116 /var/tmp/$FILEDISK2 117log_must zpool offline $TESTPOOL5 /var/tmp/$FILEDISK2 118log_must zpool export $TESTPOOL5 119log_mustnot zpool create "$TESTPOOL6" /var/tmp/$FILEDISK2 120create_pool $TESTPOOL6 /var/tmp/$FILEDISK2 121log_must poolexists $TESTPOOL6 122 123log_pass "'zpool create -f <pool> <vspec> ...' success." 124