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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28 29############################################################################### 30# 31# __stc_assertion_start 32# 33# ID: zfs_unmount_009_pos 34# 35# DESCRIPTION: 36# Verify that zfs unmount and destroy in a snapshot directory will not cause error. 37# 38# STRATEGY: 39# 1. Create a file in a zfs filesystem, snapshot it and change directory to snapshot directory 40# 2. Verify that 'zfs unmount -a' will fail and 'zfs unmount -fa' will succeed 41# 3. Verify 'ls' and 'cd /' will succeed 42# 4. 'zfs mount -a' and change directory to snapshot directory again 43# 5. Verify that zfs destroy snapshot will succeed 44# 6. Verify 'ls' and 'cd /' will succeed 45# 7. Create zfs filesystem, create a file, snapshot it and change to snapshot directory 46# 8. Verify that zpool destroy the pool will succeed 47# 9. Verify 'ls' 'cd /' 'zpool list' and etc will succeed 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2008-07-29) 54# 55# __stc_assertion_end 56# 57################################################################################ 58 59verify_runnable "both" 60 61function cleanup 62{ 63 DISK=${DISKS%% *} 64 65 for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do 66 typeset snap=$fs@$TESTSNAP 67 if snapexists $snap; then 68 log_must $ZFS destroy $snap 69 fi 70 done 71 72 if ! poolexists $TESTPOOL && is_global_zone; then 73 log_must $ZPOOL create $TESTPOOL $DISK 74 fi 75 76 if ! datasetexists $TESTPOOL/$TESTFS; then 77 log_must $ZFS create $TESTPOOL/$TESTFS 78 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 79 fi 80} 81 82function restore_dataset 83{ 84 if ! datasetexists $TESTPOOL/$TESTFS ; then 85 log_must $ZFS create $TESTPOOL/$TESTFS 86 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 87 log_must cd $TESTDIR 88 $ECHO hello > world 89 log_must $ZFS snapshot $TESTPOOL/$TESTFS@$TESTSNAP 90 log_must cd $(get_snapdir_name)/$TESTSNAP 91 fi 92} 93 94 95log_assert "zfs fource unmount and destroy in snapshot directory will not cause error." 96log_onexit cleanup 97 98for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do 99 typeset snap=$fs@$TESTSNAP 100 typeset mtpt=$(get_prop mountpoint $fs) 101 102 log_must cd $mtpt 103 $ECHO hello > world 104 log_must $ZFS snapshot $snap 105 log_must cd $(get_snapdir_name)/$TESTSNAP 106 107 log_mustnot $ZFS unmount -a 108 log_must $ZFS unmount -fa 109 log_mustnot $LS 110 log_must cd / 111 112 log_must $ZFS mount -a 113 log_must cd $mtpt 114 log_must cd $(get_snapdir_name)/$TESTSNAP 115 116 if is_global_zone || [[ $fs != $TESTPOOL ]] ; then 117 log_must $ZFS destroy -rf $fs 118 log_mustnot $LS 119 log_must cd / 120 fi 121 122 restore_dataset 123done 124 125if is_global_zone ; then 126 log_must $ZPOOL destroy -f $TESTPOOL 127 log_mustnot $LS 128 log_must cd / 129fi 130 131log_must eval $ZFS list > /dev/null 2>&1 132log_must eval $ZPOOL list > /dev/null 2>&1 133log_must eval $ZPOOL status > /dev/null 2>&1 134$ZPOOL iostat > /dev/null 2>&1 135 136log_pass "zfs fource unmount and destroy in snapshot directory will not cause error." 137