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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 .
$STF_SUITE/include
/libtest.shlib
28 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_add
/zpool_add.kshlib
32 # 'zpool add [-f]' can add large numbers of file-in-zfs-filesystem-based vdevs
33 # to the specified pool without any errors.
36 # 1. Create assigned number of files in ZFS filesystem as vdevs and use the first
37 # file to create a pool
38 # 2. Add other vdevs to the pool should get success
39 # 3 Fill in the filesystem and create a partially written file
41 # 4. Add the new file into the pool should be failed.
44 verify_runnable
"global"
48 poolexists
$TESTPOOL1 && \
49 destroy_pool
$TESTPOOL1
51 datasetexists
$TESTPOOL/$TESTFS && \
52 log_must
$ZFS destroy
-f $TESTPOOL/$TESTFS
53 poolexists
$TESTPOOL && \
54 destroy_pool
$TESTPOOL
56 if [[ -d $TESTDIR ]]; then
57 log_must
$RM -rf $TESTDIR
65 # Create a pool and fs on the assigned disk, and dynamically create large
66 # numbers of files as vdevs.(the default value is <VDEVS_NUM>)
67 # the first file will be used to create a pool for other vdevs to be added into
70 function setup_vdevs
#<disk>
74 typeset
-l largest_num
=0
75 typeset
-l slicesize
=0
80 # Get disk size for zfs filesystem
83 log_must
$ZFS create foo
/fs
84 typeset
-l fs_size
=$
(get_prop
"available" foo
/fs
)
87 #64m is the minmum size for pool
88 (( largest_num
= fs_size
/ (1024 * 1024 * 64) ))
89 if (( largest_num
< $VDEVS_NUM )); then
90 # minus $largest_num/40 to leave 2.5% space for metadata.
91 (( vdevs_num
=largest_num
- largest_num
/40 ))
96 file_size
=$
((fs_size
/ (1024 * 1024 * \
97 (vdevs_num
+ vdevs_num
/ 40))))
98 if (( file_size
> FILE_SIZE
)); then
101 # plus $vdevs_num/40 to provide enough space for metadata.
102 (( slice_size
= file_size
* (vdevs_num
+ vdevs_num
/40) ))
103 set_partition
0 "" ${slice_size}m
$disk
107 create_pool
$TESTPOOL $vdev
108 [[ -d $TESTDIR ]] && \
109 log_must
$RM -rf $TESTDIR
110 log_must
$MKDIR -p $TESTDIR
111 log_must
$ZFS create
$TESTPOOL/$TESTFS
112 log_must
$ZFS set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
114 # Create a pool first using the first file, and make subsequent files
115 # ready as vdevs to add to the pool
117 log_must
$MKFILE ${file_size}m
${TESTDIR}/file.
$count
118 create_pool
"$TESTPOOL1" "${TESTDIR}/file.$count"
119 log_must poolexists
"$TESTPOOL1"
121 while (( count
< vdevs_num
)); do # minus 1 to avoid space non-enough
122 (( count
= count
+ 1 ))
123 log_must
$MKFILE ${file_size}m
${TESTDIR}/file.
$count
124 vdevs_list
="$vdevs_list ${TESTDIR}/file.$count"
128 log_assert
" 'zpool add [-f]' can add large numbers of vdevs to the specified" \
129 " pool without any errors."
132 if [[ $DISK_ARRAY_NUM == 0 ]]; then
143 log_must
$ZPOOL add
-f "$TESTPOOL1" $vdevs_list
144 log_must iscontained
"$TESTPOOL1" "$vdevs_list"
146 (( file_size
= file_size
* (vdevs_num
/40 + 1 ) ))
147 log_mustnot
$MKFILE ${file_size}m
${TESTDIR}/broken_file
149 log_mustnot
$ZPOOL add
-f "$TESTPOOL1" ${TESTDIR}/broken_file
150 log_mustnot iscontained
"$TESTPOOL1" "${TESTDIR}/broken_file"
152 log_pass
"'zpool successfully add [-f]' can add large numbers of vdevs to the" \
153 "specified pool without any errors."