Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_004_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_004_pos.ksh (revision 292305) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_004_pos.ksh (revision 292306) @@ -1,195 +1,193 @@ #!/usr/local/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)zpool_create_004_pos.ksh 1.4 08/11/03 SMI" # . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib ################################################################################ # # __stc_assertion_start # # ID: zpool_create_004_pos # # DESCRIPTION: # 'zpool create [-f]' can create a storage pool with large number of # file-in-zfs-filesystem-based vdevs without any errors. # # STRATEGY: # 1. Create assigned number of files in ZFS filesystem as vdevs # 2. Creating a new pool based on the vdevs should get success # 3. Fill in the filesystem and create a partially writen file as vdev # 4. Add the new file into vdevs list and create a pool # 5. Creating a storage pool with the new vdevs list should be failed. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2005-08-25) # # __stc_assertion_end # ################################################################################ verify_runnable "global" VDEVS_POOL=create_004_pool function cleanup { typeset pool="" for pool in $VDEVS_POOL $TESTPOOL2 $TESTPOOL1; do poolexists $pool && \ destroy_pool $pool done if datasetexists $TESTPOOL/$TESTFS; then log_must $ZFS destroy -f $TESTPOOL/$TESTFS fi if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi if [[ -d $TESTDIR ]]; then log_must $RM -rf $TESTDIR fi } # # Create a pool and fs on the assigned disk, and dynamically create large numbers of # files as vdevs.(the default value is ) # function setup_vdevs # { typeset disk=$1 typeset -i largest_num=0 typeset -i slice_size=0 typeset vdev="" # # Get disk size for zfs filesystem # create_pool $VDEVS_POOL $disk log_must $ZFS create $VDEVS_POOL/fs typeset -il fs_size=$(get_prop "available" $VDEVS_POOL/fs) destroy_pool $VDEVS_POOL # Creating VDEVS_POOL corrupted the gpart label. We must erase the disk # before we can partition it again. - # Calling "zfs list" will wait for the asynchronous pool destroy to complete - $ZFS list > /dev/null 2>&1 cleanup_devices $disk (( largest_num = fs_size / (1024 * 1024 * ${POOL_MINSIZE}) )) if (( largest_num < $VDEVS_NUM )); then #minus $largest_num/$MD_OVERHEAD to leave space for metadata (( vdevs_num=largest_num - largest_num/$MD_OVERHEAD )) file_size=$POOL_MINSIZE vdev=$disk else vdevs_num=$VDEVS_NUM (( file_size = fs_size / \ (1024 * 1024 * (vdevs_num + vdevs_num/$MD_OVERHEAD)) )) if (( file_size > FILE_SIZE )); then # if file_size too large, the time cost will increase. # so we limit the file_size to $FILE_SIZE, and thus the # total time spent on creating file can be controlled # within $STF_TIMEOUT file_size=$FILE_SIZE fi # plus $vdevs_num/$MD_OVERHEAD to provide enough space for metadata (( slice_size = file_size * (vdevs_num + vdevs_num/$MD_OVERHEAD) )) set_partition 1 "" ${slice_size}m $disk vdev=${disk}p1 fi create_pool $TESTPOOL $vdev [[ -d $TESTDIR ]] && \ log_must $RM -rf $TESTDIR log_must $MKDIR -p $TESTDIR log_must $ZFS create $TESTPOOL/$TESTFS log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS typeset -i count=0 typeset PIDLIST="" while (( count < vdevs_num )); do $MKFILE ${file_size}m ${TESTDIR}/file.$count & PIDLIST="$PIDLIST $!" vdevs_list="$vdevs_list ${TESTDIR}/file.$count" (( count = count + 1 )) done # wait all mkfiles to finish wait $PIDLIST if (( $? != 0 )); then log_fail "create vdevs failed." fi return 0 } log_assert " 'zpool create [-f]' can create a storage pool with large numbers of vdevs " \ "without any errors." log_onexit cleanup if [[ -n $DISK ]]; then disk=$DISK else disk=$DISK0 fi log_note "Create storage pool with number of $VDEVS_NUM file vdevs should succeed." vdevs_list="" vdevs_num=$VDEVS_NUM file_size=$FILE_SIZE setup_vdevs $disk create_pool $TESTPOOL1 $vdevs_list if poolexists $TESTPOOL1; then destroy_pool $TESTPOOL1 else log_fail " Creating pool with large of numbers of file-vdevs fail." fi log_note "Creating storage pool with partially written file as vdev should be failed." left_space=$(get_prop "available" $TESTPOOL/$TESTFS) # Count the broken file size. make sure it should be greater than $left_space # so, here, we plus a number -- $file_size, this number can be any other number. (( file_size = left_space / (1024 * 1024) + file_size )) log_mustnot $MKFILE ${file_size}m ${TESTDIR}/broken_file vdevs_list="$vdevs_list ${TESTDIR}/broken_file" log_mustnot $ZPOOL create -f $TESTPOOL2 $vdevs_list log_pass "'zpool create [-f]' with $vdevs_num vdevs success."