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