1f38cb554SJohn Wren Kennedy#!/bin/ksh -p 2f38cb554SJohn Wren Kennedy# 3f38cb554SJohn Wren Kennedy# CDDL HEADER START 4f38cb554SJohn Wren Kennedy# 5f38cb554SJohn Wren Kennedy# The contents of this file are subject to the terms of the 6f38cb554SJohn Wren Kennedy# Common Development and Distribution License (the "License"). 7f38cb554SJohn Wren Kennedy# You may not use this file except in compliance with the License. 8f38cb554SJohn Wren Kennedy# 9f38cb554SJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10f38cb554SJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing. 11f38cb554SJohn Wren Kennedy# See the License for the specific language governing permissions 12f38cb554SJohn Wren Kennedy# and limitations under the License. 13f38cb554SJohn Wren Kennedy# 14f38cb554SJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each 15f38cb554SJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16f38cb554SJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the 17f38cb554SJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying 18f38cb554SJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner] 19f38cb554SJohn Wren Kennedy# 20f38cb554SJohn Wren Kennedy# CDDL HEADER END 21f38cb554SJohn Wren Kennedy# 22f38cb554SJohn Wren Kennedy 23f38cb554SJohn Wren Kennedy# 24f38cb554SJohn Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25f38cb554SJohn Wren Kennedy# Use is subject to license terms. 26f38cb554SJohn Wren Kennedy# 27f38cb554SJohn Wren Kennedy 28f38cb554SJohn Wren Kennedy# 29*1d32ba66SJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 30f38cb554SJohn Wren Kennedy# 31f38cb554SJohn Wren Kennedy 32f38cb554SJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 33f38cb554SJohn Wren Kennedy. $STF_SUITE/tests/functional/largest_pool/largest_pool.cfg 34f38cb554SJohn Wren Kennedy 35f38cb554SJohn Wren Kennedy# DESCRIPTION: 36f38cb554SJohn Wren Kennedy# The largest pool can be created and a dataset in that 37f38cb554SJohn Wren Kennedy# pool can be created and mounted. 38f38cb554SJohn Wren Kennedy# 39f38cb554SJohn Wren Kennedy# STRATEGY: 40f38cb554SJohn Wren Kennedy# create a pool which will contain a volume device. 41f38cb554SJohn Wren Kennedy# create a volume device of desired sizes. 42f38cb554SJohn Wren Kennedy# create the largest pool allowed using the volume vdev. 43f38cb554SJohn Wren Kennedy# create and mount a dataset in the largest pool. 44f38cb554SJohn Wren Kennedy# create some files in the zfs file system. 45f38cb554SJohn Wren Kennedy# do some zpool list commands and parse the output. 46f38cb554SJohn Wren Kennedy 47f38cb554SJohn Wren Kennedyverify_runnable "global" 48f38cb554SJohn Wren Kennedy 49f38cb554SJohn Wren Kennedy# 50f38cb554SJohn Wren Kennedy# Parse the results of zpool & zfs creation with specified size 51f38cb554SJohn Wren Kennedy# 52f38cb554SJohn Wren Kennedy# $1: volume size 53f38cb554SJohn Wren Kennedy# 54f38cb554SJohn Wren Kennedy# return value: 55f38cb554SJohn Wren Kennedy# 0 -> success 56f38cb554SJohn Wren Kennedy# 1 -> failure 57f38cb554SJohn Wren Kennedy# 58f38cb554SJohn Wren Kennedyfunction parse_expected_output 59f38cb554SJohn Wren Kennedy{ 60*1d32ba66SJohn Wren Kennedy UNITS=`echo $1 | sed -e 's/^\([0-9].*\)\([a-z].\)/\2/'` 61f38cb554SJohn Wren Kennedy case "$UNITS" in 62f38cb554SJohn Wren Kennedy 'mb') CHKUNIT="M" ;; 63f38cb554SJohn Wren Kennedy 'gb') CHKUNIT="G" ;; 64f38cb554SJohn Wren Kennedy 'tb') CHKUNIT="T" ;; 65f38cb554SJohn Wren Kennedy 'pb') CHKUNIT="P" ;; 66f38cb554SJohn Wren Kennedy 'eb') CHKUNIT="E" ;; 67f38cb554SJohn Wren Kennedy *) CHKUNIT="M" ;; 68f38cb554SJohn Wren Kennedy esac 69f38cb554SJohn Wren Kennedy 70f38cb554SJohn Wren Kennedy log_note "Detect zpool $TESTPOOL in this test machine." 71*1d32ba66SJohn Wren Kennedy log_must eval "zpool list $TESTPOOL > /tmp/j.$$" 72*1d32ba66SJohn Wren Kennedy log_must eval "grep $TESTPOOL /tmp/j.$$ | \ 73*1d32ba66SJohn Wren Kennedy awk '{print $2}' | grep $CHKUNIT" 74f38cb554SJohn Wren Kennedy 75f38cb554SJohn Wren Kennedy log_note "Detect the file system in this test machine." 76*1d32ba66SJohn Wren Kennedy log_must eval "df -F zfs -h > /tmp/j.$$" 77*1d32ba66SJohn Wren Kennedy log_must eval "grep $TESTPOOL /tmp/j.$$ | \ 78*1d32ba66SJohn Wren Kennedy awk '{print $2}' | grep $CHKUNIT" 79f38cb554SJohn Wren Kennedy 80f38cb554SJohn Wren Kennedy return 0 81f38cb554SJohn Wren Kennedy} 82f38cb554SJohn Wren Kennedy 83f38cb554SJohn Wren Kennedy# 84f38cb554SJohn Wren Kennedy# Check and destroy zfs, volume & zpool remove the temporary files 85f38cb554SJohn Wren Kennedy# 86f38cb554SJohn Wren Kennedyfunction cleanup 87f38cb554SJohn Wren Kennedy{ 88f38cb554SJohn Wren Kennedy log_note "Start cleanup the zfs and pool" 89f38cb554SJohn Wren Kennedy 90f38cb554SJohn Wren Kennedy if datasetexists $TESTPOOL/$TESTFS ; then 91f38cb554SJohn Wren Kennedy if ismounted $TESTPOOL/$TESTFS ; then 92*1d32ba66SJohn Wren Kennedy log_must zfs unmount $TESTPOOL/$TESTFS 93f38cb554SJohn Wren Kennedy fi 94*1d32ba66SJohn Wren Kennedy log_must zfs destroy $TESTPOOL/$TESTFS 95f38cb554SJohn Wren Kennedy fi 96f38cb554SJohn Wren Kennedy 97f38cb554SJohn Wren Kennedy destroy_pool $TESTPOOL 98f38cb554SJohn Wren Kennedy 99f38cb554SJohn Wren Kennedy datasetexists $TESTPOOL2/$TESTVOL && \ 100*1d32ba66SJohn Wren Kennedy log_must zfs destroy $TESTPOOL2/$TESTVOL 101f38cb554SJohn Wren Kennedy 102f38cb554SJohn Wren Kennedy destroy_pool $TESTPOOL2 103f38cb554SJohn Wren Kennedy 104*1d32ba66SJohn Wren Kennedy rm -f /tmp/j.* > /dev/null 105f38cb554SJohn Wren Kennedy} 106f38cb554SJohn Wren Kennedy 107f38cb554SJohn Wren Kennedylog_assert "The largest pool can be created and a dataset in that" \ 108f38cb554SJohn Wren Kennedy "pool can be created and mounted." 109f38cb554SJohn Wren Kennedy 110f38cb554SJohn Wren Kennedy# Set trigger. When the test case exit, cleanup is executed. 111f38cb554SJohn Wren Kennedylog_onexit cleanup 112f38cb554SJohn Wren Kennedy 113f38cb554SJohn Wren Kennedy# ----------------------------------------------------------------------- 114f38cb554SJohn Wren Kennedy# volume sizes with unit designations. 115f38cb554SJohn Wren Kennedy# 116f38cb554SJohn Wren Kennedy# Note: specifying the number '1' as size will not give the correct 117f38cb554SJohn Wren Kennedy# units for 'df'. It must be greater than one. 118f38cb554SJohn Wren Kennedy# ----------------------------------------------------------------------- 119f38cb554SJohn Wren Kennedytypeset str 120f38cb554SJohn Wren Kennedytypeset -i ret 121f38cb554SJohn Wren Kennedyfor volsize in $VOLSIZES; do 122f38cb554SJohn Wren Kennedy log_note "Create a pool which will contain a volume device" 123f38cb554SJohn Wren Kennedy create_pool $TESTPOOL2 "$DISKS" 124f38cb554SJohn Wren Kennedy 125f38cb554SJohn Wren Kennedy log_note "Create a volume device of desired sizes: $volsize" 126*1d32ba66SJohn Wren Kennedy str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) 127f38cb554SJohn Wren Kennedy ret=$? 128f38cb554SJohn Wren Kennedy if (( ret != 0 )); then 129*1d32ba66SJohn Wren Kennedy if [[ $(isainfo -b) == 32 && \ 130f38cb554SJohn Wren Kennedy $str == *${VOL_LIMIT_KEYWORD1}* || \ 131f38cb554SJohn Wren Kennedy $str == *${VOL_LIMIT_KEYWORD2}* || \ 132f38cb554SJohn Wren Kennedy $str == *${VOL_LIMIT_KEYWORD3}* ]] 133f38cb554SJohn Wren Kennedy then 134f38cb554SJohn Wren Kennedy log_unsupported \ 135f38cb554SJohn Wren Kennedy "Max volume size is 1TB on 32-bit systems." 136f38cb554SJohn Wren Kennedy else 137*1d32ba66SJohn Wren Kennedy log_fail "zfs create -sV $volsize $TESTPOOL2/$TESTVOL" 138f38cb554SJohn Wren Kennedy fi 139f38cb554SJohn Wren Kennedy fi 140f38cb554SJohn Wren Kennedy 141f38cb554SJohn Wren Kennedy log_note "Create the largest pool allowed using the volume vdev" 142f38cb554SJohn Wren Kennedy create_pool $TESTPOOL "$VOL_PATH" 143f38cb554SJohn Wren Kennedy 144f38cb554SJohn Wren Kennedy log_note "Create a zfs file system in the largest pool" 145*1d32ba66SJohn Wren Kennedy log_must zfs create $TESTPOOL/$TESTFS 146f38cb554SJohn Wren Kennedy 147f38cb554SJohn Wren Kennedy log_note "Parse the execution result" 148f38cb554SJohn Wren Kennedy parse_expected_output $volsize 149f38cb554SJohn Wren Kennedy 150f38cb554SJohn Wren Kennedy log_note "unmount this zfs file system $TESTPOOL/$TESTFS" 151*1d32ba66SJohn Wren Kennedy log_must zfs unmount $TESTPOOL/$TESTFS 152f38cb554SJohn Wren Kennedy 153f38cb554SJohn Wren Kennedy log_note "Destroy zfs, volume & zpool" 154*1d32ba66SJohn Wren Kennedy log_must zfs destroy $TESTPOOL/$TESTFS 155f38cb554SJohn Wren Kennedy destroy_pool $TESTPOOL 156*1d32ba66SJohn Wren Kennedy log_must zfs destroy $TESTPOOL2/$TESTVOL 157f38cb554SJohn Wren Kennedy destroy_pool $TESTPOOL2 158f38cb554SJohn Wren Kennedydone 159f38cb554SJohn Wren Kennedy 160f38cb554SJohn Wren Kennedylog_pass "Dateset can be created, mounted & destroy in largest pool succeeded." 161