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) 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 > /tmp/j.$$" 72 log_must eval "grep $TESTPOOL /tmp/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 > /tmp/j.$$" 77 log_must eval "grep $TESTPOOL /tmp/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 log_must zfs destroy $TESTPOOL/$TESTFS 95 fi 96 97 destroy_pool $TESTPOOL 98 99 datasetexists $TESTPOOL2/$TESTVOL && \ 100 log_must zfs destroy $TESTPOOL2/$TESTVOL 101 102 destroy_pool $TESTPOOL2 103 104 rm -f /tmp/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 120typeset -i ret 121for volsize in $VOLSIZES; do 122 log_note "Create a pool which will contain a volume device" 123 create_pool $TESTPOOL2 "$DISKS" 124 125 log_note "Create a volume device of desired sizes: $volsize" 126 str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) 127 ret=$? 128 if (( ret != 0 )); then 129 if [[ $(isainfo -b) == 32 && \ 130 $str == *${VOL_LIMIT_KEYWORD1}* || \ 131 $str == *${VOL_LIMIT_KEYWORD2}* || \ 132 $str == *${VOL_LIMIT_KEYWORD3}* ]] 133 then 134 log_unsupported \ 135 "Max volume size is 1TB on 32-bit systems." 136 else 137 log_fail "zfs create -sV $volsize $TESTPOOL2/$TESTVOL" 138 fi 139 fi 140 141 log_note "Create the largest pool allowed using the volume vdev" 142 create_pool $TESTPOOL "$VOL_PATH" 143 144 log_note "Create a zfs file system in the largest pool" 145 log_must zfs create $TESTPOOL/$TESTFS 146 147 log_note "Parse the execution result" 148 parse_expected_output $volsize 149 150 log_note "unmount this zfs file system $TESTPOOL/$TESTFS" 151 log_must zfs unmount $TESTPOOL/$TESTFS 152 153 log_note "Destroy zfs, volume & zpool" 154 log_must zfs destroy $TESTPOOL/$TESTFS 155 destroy_pool $TESTPOOL 156 log_must zfs destroy $TESTPOOL2/$TESTVOL 157 destroy_pool $TESTPOOL2 158done 159 160log_pass "Dateset can be created, mounted & destroy in largest pool succeeded." 161