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# Verify zpool add succeed when adding vdevs with matching redundancy. 38# 39# STRATEGY: 40# 1. Create base filesystem to hold virtual disk files. 41# 2. Create several files == $MINVDEVSIZE. 42# 3. Create pool with given redundancy. 43# 3. Verify 'zpool add' succeed with with matching redundancy. 44# 45 46verify_runnable "global" 47 48function cleanup 49{ 50 datasetexists $TESTPOOL1 && destroy_pool $TESTPOOL1 51 datasetexists $TESTPOOL && destroy_pool $TESTPOOL 52} 53 54 55log_assert "Verify 'zpool add' succeed with keywords combination." 56log_onexit cleanup 57 58create_pool $TESTPOOL $DISKS 59mntpnt=$(get_prop mountpoint $TESTPOOL) 60 61typeset -i i=0 62while ((i < 10)); do 63 log_must truncate -s $MINVDEVSIZE $mntpnt/vdev$i 64 65 eval vdev$i=$mntpnt/vdev$i 66 ((i += 1)) 67done 68 69set -A redundancy0_create_args \ 70 "$vdev0" 71 72set -A redundancy1_create_args \ 73 "mirror $vdev0 $vdev1" \ 74 "raidz1 $vdev0 $vdev1" 75 76set -A redundancy2_create_args \ 77 "mirror $vdev0 $vdev1 $vdev2" \ 78 "raidz2 $vdev0 $vdev1 $vdev2" 79 80set -A redundancy3_create_args \ 81 "mirror $vdev0 $vdev1 $vdev2 $vdev3" \ 82 "raidz3 $vdev0 $vdev1 $vdev2 $vdev3" 83 84set -A redundancy0_add_args \ 85 "$vdev5" \ 86 "$vdev5 $vdev6" 87 88set -A redundancy1_add_args \ 89 "mirror $vdev5 $vdev6" \ 90 "raidz1 $vdev5 $vdev6" \ 91 "raidz1 $vdev5 $vdev6 mirror $vdev7 $vdev8" \ 92 "mirror $vdev5 $vdev6 raidz1 $vdev7 $vdev8" 93 94set -A redundancy2_add_args \ 95 "mirror $vdev5 $vdev6 $vdev7" \ 96 "raidz2 $vdev5 $vdev6 $vdev7" 97 98set -A redundancy3_add_args \ 99 "mirror $vdev5 $vdev6 $vdev7 $vdev8" \ 100 "raidz3 $vdev5 $vdev6 $vdev7 $vdev8" 101 102typeset -i j=0 103 104function zpool_create_add 105{ 106 typeset -n create_args=$1 107 typeset -n add_args=$2 108 109 i=0 110 while ((i < ${#create_args[@]})); do 111 j=0 112 while ((j < ${#add_args[@]})); do 113 log_must zpool create $TESTPOOL1 ${create_args[$i]} 114 log_must zpool add $TESTPOOL1 ${add_args[$j]} 115 log_must zpool destroy -f $TESTPOOL1 116 117 ((j += 1)) 118 done 119 ((i += 1)) 120 done 121} 122 123function zpool_create_forced_add 124{ 125 typeset -n create_args=$1 126 typeset -n add_args=$2 127 128 i=0 129 while ((i < ${#create_args[@]})); do 130 j=0 131 while ((j < ${#add_args[@]})); do 132 log_must zpool create $TESTPOOL1 ${create_args[$i]} 133 log_mustnot zpool add $TESTPOOL1 ${add_args[$j]} 134 log_must zpool add -f $TESTPOOL1 ${add_args[$j]} 135 log_must zpool destroy -f $TESTPOOL1 136 137 ((j += 1)) 138 done 139 ((i += 1)) 140 done 141} 142 143zpool_create_add redundancy0_create_args redundancy0_add_args 144zpool_create_add redundancy1_create_args redundancy1_add_args 145zpool_create_add redundancy2_create_args redundancy2_add_args 146zpool_create_add redundancy3_create_args redundancy3_add_args 147 148zpool_create_forced_add redundancy0_create_args redundancy1_add_args 149zpool_create_forced_add redundancy0_create_args redundancy2_add_args 150zpool_create_forced_add redundancy0_create_args redundancy3_add_args 151 152zpool_create_forced_add redundancy1_create_args redundancy0_add_args 153zpool_create_forced_add redundancy1_create_args redundancy2_add_args 154zpool_create_forced_add redundancy1_create_args redundancy3_add_args 155 156zpool_create_forced_add redundancy2_create_args redundancy0_add_args 157zpool_create_forced_add redundancy2_create_args redundancy1_add_args 158zpool_create_forced_add redundancy2_create_args redundancy3_add_args 159 160zpool_create_forced_add redundancy3_create_args redundancy0_add_args 161zpool_create_forced_add redundancy3_create_args redundancy1_add_args 162zpool_create_forced_add redundancy3_create_args redundancy2_add_args 163 164log_pass "'zpool add' succeed with keywords combination." 165