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 https://opensource.org/licenses/CDDL-1.0. 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) 2013, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/largest_pool/largest_pool.cfg 34 35# DESCRIPTION: 36# The largest pool can be created and a dataset in that 37# pool can be created and mounted. 38# 39# STRATEGY: 40# create a pool which will contain a volume device. 41# create a volume device of desired sizes. 42# create the largest pool allowed using the volume vdev. 43# create and mount a dataset in the largest pool. 44# create some files in the zfs file system. 45# do some zpool list commands and parse the output. 46 47verify_runnable "global" 48 49# 50# Parse the results of zpool & zfs creation with specified size 51# 52# $1: volume size 53# 54# return value: 55# 0 -> success 56# 1 -> failure 57# 58function parse_expected_output 59{ 60 UNITS=`echo $1 | sed -e 's/^\([0-9].*\)\([a-z].\)/\2/'` 61 case "$UNITS" in 62 'mb') CHKUNIT="M" ;; 63 'gb') CHKUNIT="G" ;; 64 'tb') CHKUNIT="T" ;; 65 'pb') CHKUNIT="P" ;; 66 'eb') CHKUNIT="E" ;; 67 *) CHKUNIT="M" ;; 68 esac 69 70 log_note "Detect zpool $TESTPOOL in this test machine." 71 log_must eval "zpool list $TESTPOOL > $TEST_BASE_DIR/j.$$" 72 log_must eval "grep $TESTPOOL $TEST_BASE_DIR/j.$$ | \ 73 awk '{print $2}' | grep $CHKUNIT" 74 75 log_note "Detect the file system in this test machine." 76 log_must eval "df -F zfs -h > $TEST_BASE_DIR/j.$$" 77 log_must eval "grep $TESTPOOL $TEST_BASE_DIR/j.$$ | \ 78 awk '{print $2}' | grep $CHKUNIT" 79 80 return 0 81} 82 83# 84# Check and destroy zfs, volume & zpool remove the temporary files 85# 86function cleanup 87{ 88 log_note "Start cleanup the zfs and pool" 89 90 if datasetexists $TESTPOOL/$TESTFS ; then 91 if ismounted $TESTPOOL/$TESTFS ; then 92 log_must zfs unmount $TESTPOOL/$TESTFS 93 fi 94 destroy_dataset $TESTPOOL/$TESTFS 95 fi 96 97 destroy_pool $TESTPOOL 98 99 datasetexists $TESTPOOL2/$TESTVOL && \ 100 destroy_dataset $TESTPOOL2/$TESTVOL 101 102 destroy_pool $TESTPOOL2 103 104 rm -f $TEST_BASE_DIR/j.* > /dev/null 105} 106 107log_assert "The largest pool can be created and a dataset in that" \ 108 "pool can be created and mounted." 109 110# Set trigger. When the test case exit, cleanup is executed. 111log_onexit cleanup 112 113# ----------------------------------------------------------------------- 114# volume sizes with unit designations. 115# 116# Note: specifying the number '1' as size will not give the correct 117# units for 'df'. It must be greater than one. 118# ----------------------------------------------------------------------- 119typeset str 120for volsize in $VOLSIZES; do 121 log_note "Create a pool which will contain a volume device" 122 log_must create_pool $TESTPOOL2 "$DISKS" 123 124 log_note "Create a volume device of desired sizes: $volsize" 125 if ! str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1); then 126 if [[ is_32bit && \ 127 $str == *${VOL_LIMIT_KEYWORD1}* || \ 128 $str == *${VOL_LIMIT_KEYWORD2}* || \ 129 $str == *${VOL_LIMIT_KEYWORD3}* ]] 130 then 131 log_unsupported \ 132 "Max volume size is 1TB on 32-bit systems." 133 else 134 log_fail "zfs create -sV $volsize $TESTPOOL2/$TESTVOL" 135 fi 136 fi 137 block_device_wait 138 139 log_note "Create the largest pool allowed using the volume vdev" 140 log_must create_pool $TESTPOOL "$VOL_PATH" 141 142 log_note "Create a zfs file system in the largest pool" 143 log_must zfs create $TESTPOOL/$TESTFS 144 145 log_note "Parse the execution result" 146 parse_expected_output $volsize 147 148 log_note "unmount this zfs file system $TESTPOOL/$TESTFS" 149 log_must zfs unmount $TESTPOOL/$TESTFS 150 151 log_note "Destroy zfs, volume & zpool" 152 log_must zfs destroy $TESTPOOL/$TESTFS 153 destroy_pool $TESTPOOL 154 log_must_busy zfs destroy $TESTPOOL2/$TESTVOL 155 destroy_pool $TESTPOOL2 156done 157 158log_pass "Dataset can be created, mounted & destroy in largest pool succeeded." 159