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