1 #!/usr/local/bin/ksh93 -p
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.
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.
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]
26 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ident "@(#)zpool_add_006_pos.ksh 1.5 09/06/22 SMI"
31 . $STF_SUITE/include/libtest.kshlib
32 . $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib
34 ################################################################################
36 # __stc_assertion_start
38 # ID: zpool_add_006_pos
41 # 'zpool add [-f]' can add large numbers of file-in-zfs-filesystem-based vdevs
42 # to the specified pool without any errors.
45 # 1. Create assigned number of files in ZFS filesystem as vdevs and use the first
46 # file to create a pool
47 # 2. Add other vdevs to the pool should get success
48 # 3 Fill in the filesystem and create a partially written file
50 # 4. Add the new file into the pool should be failed.
52 # TESTABILITY: explicit
54 # TEST_AUTOMATION_LEVEL: automated
56 # CODING_STATUS: COMPLETED (2005-10-09)
60 ################################################################################
62 verify_runnable "global"
66 poolexists $TESTPOOL1 && \
67 destroy_pool $TESTPOOL1
69 poolexists $TESTPOOL && \
70 destroy_pool $TESTPOOL
72 if [[ -d $TESTDIR ]]; then
73 log_must $RM -rf $TESTDIR
79 # Create a pool and fs on the assigned disk, and dynamically create large
80 # numbers of files as vdevs.(the default value is <VDEVS_NUM>)
81 # the first file will be used to create a pool for other vdevs to be added into
84 function setup_vdevs #<disk>
88 typeset -i largest_num=0
89 typeset -i slicesize=0
92 fs_size=$(get_available_disk_size $disk)
94 # 64M is the minimum size for the pool
95 (( largest_num = fs_size / (1024 * 1024 * 64) ))
96 if (( largest_num < $VDEVS_NUM )); then
97 # Minus $largest_num/20 to leave 5% space for metadata.
98 (( vdevs_num=largest_num - largest_num/20 ))
102 (( file_size = fs_size / (1024 * 1024 * (vdevs_num + vdevs_num/20)) ))
103 if (( file_size > FILE_SIZE )); then
106 # Plus $vdevs_num/20 to provide enough space for metadata.
107 (( slice_size = file_size * (vdevs_num + vdevs_num/20) ))
108 wipe_partition_table $disk
109 set_partition 0 "" ${slice_size}m $disk
113 create_pool $TESTPOOL $vdev
114 [[ -d $TESTDIR ]] && \
115 log_must $RM -rf $TESTDIR
116 log_must $MKDIR -p $TESTDIR
117 log_must $ZFS create $TESTPOOL/$TESTFS
118 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
120 # Create a pool first using the first file, and make subsequent files ready
121 # as vdevs to add to the pool
123 vdev=${TESTDIR}/file.$count
124 VDEV_SIZE=${file_size}m
125 log_must create_vdevs ${TESTDIR}/file.$count
126 create_pool "$TESTPOOL1" "${TESTDIR}/file.$count"
127 log_must poolexists "$TESTPOOL1"
129 while (( count < vdevs_num )); do # minus 1 to avoid space non-enough
130 (( count = count + 1 ))
131 log_must create_vdevs ${TESTDIR}/file.$count
132 vdevs_list="$vdevs_list ${TESTDIR}/file.$count"
137 log_assert " 'zpool add [-f]' can add large numbers of vdevs to the specified" \
138 " pool without any errors."
146 log_must $ZPOOL add -f "$TESTPOOL1" $vdevs_list
147 log_must iscontained "$TESTPOOL1" "$vdevs_list"
149 log_pass "'zpool successfully add [-f]' can add large numbers of vdevs to the" \
150 "specified pool without any errors."