1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg 19. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib 20 21################################################################################ 22# 23# Deferred destroyed snapshots remain until the last hold is released. 24# 25# 1. Create test environment without clones. 26# 2. 'zfs hold <tag1> <snap>' 27# 3. 'zfs destroy -d <snap>' 28# 4. Sequence of holds/releases including invalid ones that should fail. 29# 4. Verify snapshot still exists. 30# 5. Release all holds. 31# 6. Verify that the snapshot is destroyed. 32# 33################################################################################ 34 35function test_snap_run 36{ 37 typeset dstype=$1 38 39 snap=$(eval echo \$${dstype}SNAP) 40 log_must zfs hold zfstest1 $snap 41 log_must zfs destroy -d $snap 42 log_must datasetexists $snap 43 log_must eval "[[ $(get_prop defer_destroy $snap) == 'on' ]]" 44 45 log_must zfs hold zfstest2 $snap 46 log_mustnot zfs hold zfstest1 $snap 47 log_mustnot zfs hold zfstest2 $snap 48 49 log_must zfs release zfstest1 $snap 50 log_must datasetexists $snap 51 log_mustnot zfs release zfstest1 $snap 52 log_must datasetexists $snap 53 log_mustnot zfs release zfstest3 $snap 54 log_must datasetexists $snap 55 56 log_must zfs release zfstest2 $snap 57 log_mustnot datasetexists $snap 58} 59 60log_assert "deferred destroyed snapshots remain until last hold is released" 61log_onexit cleanup_testenv 62 63setup_testenv snap 64 65for dstype in FS VOL; do 66 if [[ $dstype == VOL ]]; then 67 if is_global_zone; then 68 test_snap_run $dstype 69 fi 70 else 71 test_snap_run $dstype 72 fi 73done 74 75log_pass "deferred destroyed snapshots remain until last hold is released" 76