1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2012 by Delphix. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg 23 24# 25# DESCRIPTION: 26# 'zfs destroy -R <snapshot>' can destroy all the child 27# snapshots and preserves all the nested datasetss. 28# 29# STRATEGY: 30# 1. Create nested datasets in the storage pool. 31# 2. Create recursive snapshots for all the nested datasets. 32# 3. Verify when snapshots are destroyed recursively, all 33# the nested datasets still exist. 34# 35 36verify_runnable "both" 37 38log_assert "Verify 'zfs destroy -R <snapshot>' does not destroy" \ 39 "nested datasets." 40log_onexit cleanup 41 42datasets="$TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1/$TESTFS2 43 $TESTPOOL/$TESTFS1/$TESTFS2/$TESTFS3" 44 45function cleanup 46{ 47 for ds in $datasets; do 48 datasetexists $ds && $ZFS destroy -rf $ds 49 done 50} 51 52# create nested datasets 53log_must $ZFS create -p $TESTPOOL/$TESTFS1/$TESTFS2/$TESTFS3 54 55# verify dataset creation 56for ds in $datasets; do 57 datasetexists $ds || log_fail "Create $ds dataset fail." 58done 59 60# create recursive nestedd snapshot 61log_must $ZFS snapshot -r $TESTPOOL/$TESTFS1@snap 62for ds in $datasets; do 63 datasetexists $ds@snap || log_fail "Create $ds@snap snapshot fail." 64done 65 66# destroy nested snapshot recursively 67log_must $ZFS destroy -R $TESTPOOL/$TESTFS1@snap 68 69# verify snapshot destroy 70for ds in $datasets; do 71 datasetexists $ds@snap && log_fail "$ds@snap exists. Destroy failed!" 72done 73 74# verify nested datasets still exist 75for ds in $datasets; do 76 datasetexists $ds || log_fail "Recursive snapshot destroy deleted $ds" 77done 78 79log_pass "'zfs destroy -R <snapshot>' works as expected." 80