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) 2016, 2017 by Delphix. All rights reserved. 15# 16 17. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib 18 19# 20# DESCRIPTION: 21# Multiple interacting promotions in a single txg should succeed. 22# 23 24verify_runnable "global" 25 26fs=$TESTPOOL/$TESTFS/testchild 27clone1=$TESTPOOL/$TESTFS/testchild_clone1 28clone2=$TESTPOOL/$TESTFS/testchild_clone2 29snap1=$fs@testchild_snap1 30snap2=$clone1@testchild_snap2 31 32function cleanup 33{ 34 for to_destroy in $fs $clone1 $clone2; do 35 destroy_dataset $to_destroy "-R" 36 done 37} 38 39log_onexit cleanup 40 41# 42# Create a chain of clones and snapshots: 43# 44# snap1 -----------> fs 45# \--> snap2 --> clone1 46# \---> clone2 47# 48# Then promote clone2 twice, resulting in: 49# 50# snap1 --> snap2 --> clone2 51# \ \---> clone1 52# \------------> fs 53# 54# We then attempt to destroy clone1, which should succeed since it no 55# longer has any dependents. 56# 57log_must zfs create $fs 58log_must zfs snapshot $snap1 59log_must zfs clone $snap1 $clone1 60log_must zfs snapshot $snap2 61log_must zfs clone $snap2 $clone2 62 63log_must zfs unmount -f $clone1 64 65log_must_program_sync $TESTPOOL - <<-EOF 66 assert(zfs.sync.promote("$clone2") == 0) 67 assert(zfs.sync.promote("$clone2") == 0) 68 assert(zfs.sync.destroy("$clone1") == 0) 69EOF 70 71log_pass "Multiple promotes and destroying a demoted fs in one txg works." 72