1#! /usr/local/bin/ksh93 -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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/zvol/zvol_common.kshlib 29 30############################################################################### 31# 32# __stc_assertion_start 33# 34# ID: zvol_misc_004_pos 35# 36# DESCRIPTION: 37# Verify permit to create snapshot over active dumpswap zvol. 38# 39# STRATEGY: 40# 1. Create a ZFS volume 41# 2. Set the volume as dump or swap 42# 3. Verify create snapshot over the zvol succeed. 43# 44# TESTABILITY: explicit 45# 46# TEST_AUTOMATION_LEVEL: automated 47# 48# CODING_STATUS: COMPLETED (2008-01-07) 49# 50# __stc_assertion_end 51# 52################################################################################ 53 54verify_runnable "global" 55 56function cleanup 57{ 58 typeset dumpdev=$(get_dumpdevice) 59 if [[ $dumpdev != $savedumpdev ]] ; then 60 safe_dumpadm $savedumpdev 61 fi 62 63 $SWAP -l | $GREP -w $voldev > /dev/null 2>&1 64 if (( $? == 0 )); then 65 log_must $SWAP -d $voldev 66 fi 67 68 typeset snap 69 for snap in snap0 snap1 ; do 70 if datasetexists $TESTPOOL/$TESTVOL@$snap ; then 71 log_must $ZFS destroy $TESTPOOL/$TESTVOL@$snap 72 fi 73 done 74} 75 76function verify_snapshot 77{ 78 typeset volume=$1 79 80 log_must $ZFS snapshot $volume@snap0 81 log_must $ZFS snapshot $volume@snap1 82 log_must datasetexists $volume@snap0 $volume@snap1 83 84 log_must $ZFS destroy $volume@snap1 85 log_must $ZFS snapshot $volume@snap1 86 87 log_mustnot $ZFS rollback -r $volume@snap0 88 log_must datasetexists $volume@snap0 89 log_must datasetexists $volume@snap1 90 91 log_must $ZFS destroy -r $volume@snap0 92} 93 94log_assert "Verify permit to create snapshot over dumpswap." 95if ! is_dumpswap_supported $TESTPOOL ; then 96 log_unsupported "dumpswap not currently supported." 97fi 98log_onexit cleanup 99 100test_requires DUMPADM 101 102voldev=/dev/zvol/$TESTPOOL/$TESTVOL 103savedumpdev=$(get_dumpdevice) 104 105# create snapshot over dump zvol 106safe_dumpadm $voldev 107log_must is_zvol_dumpified $TESTPOOL/$TESTVOL 108 109verify_snapshot $TESTPOOL/$TESTVOL 110 111safe_dumpadm $savedumpdev 112log_mustnot is_zvol_dumpified $TESTPOOL/$TESTVOL 113 114# create snapshot over swap zvol 115 116log_must $SWAP -a $voldev 117log_mustnot is_zvol_dumpified $TESTPOOL/$TESTVOL 118 119verify_snapshot $TESTPOOL/$TESTVOL 120 121log_must $SWAP -d $voldev 122log_mustnot is_zvol_dumpified $TESTPOOL/$TESTVOL 123 124log_pass "Create snapshot over dumpswap zvol succeed." 125