4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013 by Delphix. All rights reserved.
31 . $STF_SUITE/include/libtest.shlib
32 . $STF_SUITE/tests/functional/zvol/zvol.cfg
35 # Create a simple zvol volume
37 # Where disk_device: is the name of the disk to be used
38 # volume_size: is the size of the volume, e.g. 2G
40 function default_zvol_setup # disk_device volume_size
47 create_pool $TESTPOOL "$disk"
49 log_must $ZFS create -V $size $TESTPOOL/$TESTVOL
52 set_dumpsize $TESTPOOL/$TESTVOL
56 # Destroy the default zvol which was setup using
57 # default_zvol_setup().
59 function default_zvol_cleanup
61 if datasetexists $TESTPOOL/$TESTVOL ; then
62 log_must $ZFS destroy $TESTPOOL/$TESTVOL
65 destroy_pool $TESTPOOL
68 function get_dumpdevice
70 typeset ret=$($DUMPADM | $GREP "Dump device:" | $AWK '{print $3}')
78 if [[ -z $volume ]] ; then
79 log_note "No volume specified."
83 log_must $ZFS set volsize=64m $volume
86 output=$($DUMPADM -d ${ZVOL_DEVDIR}/$volume 2>&1 | \
87 $TAIL -1 | $AWK '{print $3}')
89 if [[ -n $output ]]; then
90 (( output = output / 1024 / 1024 ))
91 (( output = output + output / 5 ))
92 log_must $ZFS set volsize=${output}m $volume
103 if [[ -z $device || $device == "none" ]] ; then
104 log_note "No dump device volume specified."
107 if [[ $device == "${ZVOL_DEVDIR}/"* ]] ; then
108 typeset volume=${device#${ZVOL_DEVDIR}/}
110 log_must $DUMPADM -d $device
113 if ! is_swap_inuse $device ; then
114 log_must $SWAP -a $device
116 log_must $DUMPADM -d swap
120 function is_zvol_dumpified
124 if [[ -z $volume ]] ; then
125 log_note "No volume specified."
129 $ZDB -dddd $volume 2 | $GREP "dumpsize" > /dev/null 2>&1
133 function is_swap_inuse
137 if [[ -z $device ]] ; then
138 log_note "No device specified."
142 $SWAP -l | $GREP -w $device > /dev/null 2>&1