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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
36 # Verify that zfs unmount and destroy in a snapshot directory will not cause error.
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
50 verify_runnable
"both"
56 for fs
in $TESTPOOL/$TESTFS $TESTPOOL ; do
57 typeset snap
=$fs@
$TESTSNAP
58 if snapexists
$snap; then
59 log_must zfs destroy
$snap
63 if ! poolexists
$TESTPOOL && is_global_zone
; then
64 log_must zpool create
$TESTPOOL $DISK
67 if ! datasetexists
$TESTPOOL/$TESTFS; then
68 log_must zfs create
$TESTPOOL/$TESTFS
69 log_must zfs
set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
73 function restore_dataset
75 if ! datasetexists
$TESTPOOL/$TESTFS ; then
76 log_must zfs create
$TESTPOOL/$TESTFS
77 log_must zfs
set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
80 log_must zfs snapshot
$TESTPOOL/$TESTFS@
$TESTSNAP
81 log_must
cd .zfs
/snapshot
/$TESTSNAP
86 log_assert
"zfs fource unmount and destroy in snapshot directory will not cause error."
89 for fs
in $TESTPOOL/$TESTFS $TESTPOOL ; do
90 typeset snap
=$fs@
$TESTSNAP
91 typeset mtpt
=$
(get_prop mountpoint
$fs)
95 log_must zfs snapshot
$snap
96 log_must
cd .zfs
/snapshot
/$TESTSNAP
98 log_mustnot zfs unmount
-a
99 log_must zfs unmount
-fa
103 log_must zfs mount
-a
105 log_must
cd .zfs
/snapshot
/$TESTSNAP
107 if is_global_zone ||
[[ $fs != $TESTPOOL ]] ; then
108 log_must zfs destroy
-rf $fs
116 if is_global_zone
; then
117 log_must zpool destroy
-f $TESTPOOL
122 log_must
eval zfs list
> /dev
/null
2>&1
123 log_must
eval zpool list
> /dev
/null
2>&1
124 log_must
eval zpool status
> /dev
/null
2>&1
125 zpool iostat
> /dev
/null
2>&1
127 log_pass
"zfs fource unmount and destroy in snapshot directory will not cause error."