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, 2016 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
39 # block_size: is the block size of the volume
41 function default_zvol_setup # disk_device volume_size block_size
50 create_pool $TESTPOOL "$disk"
52 if [ -n "$blocksize" ]; then
53 create_args="-b $blocksize"
56 log_must zfs create $create_args -V $size $TESTPOOL/$TESTVOL
61 # Destroy the default zvol which was setup using
62 # default_zvol_setup().
64 function default_zvol_cleanup
66 if datasetexists $TESTPOOL/$TESTVOL ; then
67 log_must zfs destroy $TESTPOOL/$TESTVOL
70 destroy_pool $TESTPOOL
73 function get_dumpdevice
75 typeset ret=$(dumpadm | grep "Dump device:" | awk '{print $3}')
83 if [[ -z $volume ]] ; then
84 log_note "No volume specified."
88 log_must zfs set volsize=64m $volume
91 output=$(dumpadm -d /dev/zvol/dsk/$volume 2>&1 | \
92 tail -1 | awk '{print $3}')
94 if [[ -n $output ]]; then
95 (( output = output / 1024 / 1024 ))
96 (( output = output + output / 5 ))
97 log_must zfs set volsize=${output}m $volume
104 function safe_dumpadm
108 if [[ -z $device || $device == "none" ]] ; then
109 log_note "No dump device volume specified."
112 if [[ $device == "${ZVOL_DEVDIR}/"* ]] ; then
113 typeset volume=${device#${ZVOL_DEVDIR}/}
115 log_must dumpadm -d $device
122 if ! is_swap_inuse $device ; then
124 log_must swapctl -a $device
126 log_must swap -a $device
130 log_must dumpon $device
132 log_must dumpadm -d swap
137 function is_zvol_dumpified
141 if [[ -z $volume ]] ; then
142 log_note "No volume specified."
146 zdb -dddd $volume 2 | grep "dumpsize" > /dev/null 2>&1