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 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22 23# 24# DESCRIPTION: 25# Deeply nested clones can be created and destroyed successfully 26# 27# STRATEGY: 28# 1. Create a deeply nested chain of clones 29# 2. Verify we can promote and destroy datasets in the chain without issues 30# NOTE: 31# Ported from scripts used to reproduce issue #3959 and #7279 32# 33 34verify_runnable "both" 35 36function cleanup 37{ 38 destroy_dataset "$clonesfs" "-rRf" 39} 40log_onexit cleanup 41 42log_assert "Deeply nested clones should be created and destroyed without issues" 43 44snapname='snap' 45snaprename='temporary-snap' 46clonesfs="$TESTPOOL/$TESTFS1" 47 48# NOTE: set mountpoint=none to avoid mount/umount calls and speed up the process 49log_must zfs create -o mountpoint=none $clonesfs 50log_must zfs create $clonesfs/0 51dsname="$clonesfs/0@$snapname" 52log_must zfs snapshot $dsname 53 54# 1. Create a deeply nested chain of clones 55for c in {1..250}; do 56 log_must zfs clone $dsname $clonesfs/$c 57 dsname="$clonesfs/$c@$snapname" 58 log_must zfs snapshot $dsname 59done 60 61# 2. Verify we can promote and destroy datasets in the chain without issues 62for c in {0..249}; do 63 log_must zfs rename $clonesfs/$c@$snapname $clonesfs/$c@$snaprename 64 log_must zfs promote $clonesfs/$((c+1)) 65 log_must zfs destroy -r $clonesfs/$c 66 log_must zfs destroy $clonesfs/$((c+1))@$snaprename 67done 68 69log_pass "Deeply nested clones can be created and destroyed successfully" 70