#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
#
# DESCRIPTION:
# 'zfs destroy -r|-rf|-R|-Rf <fs|ctr|vol|snap>' should recursively destroy
# all children and clones based on options.
#
# STRATEGY:
# 1. Create test environment according to options. There are three test
# models can be created. Only ctr, fs & vol; with snap; with clone.
# 2. According to option, make the dataset busy or not.
# 3. Run 'zfs destroy [-rRf] <dataset>'
# 4. According to dataset and option, check if get the expected results.
#
verify_runnable "both"
#
# According to parameters, 1st, create suitable testing environment. 2nd,
# run 'zfs destroy $opt <dataset>'. 3rd, check the system status.
#
# $1 option of 'zfs destroy'
# $2 dataset will be destroied.
#
function test_n_check
{
typeset opt=$1
typeset dtst=$2
if ! is_global_zone ; then
log_note "UNSUPPORTED: Volume are unavailable in LZ."
return
fi
fi
# '-f' has no effect on non-filesystems
if [[ $opt == -f ]]; then
"leaf FS."
return
fi
fi
# Clean the test environment and make it clear.
if datasetexists $CTR; then
fi
# According to option create test compatible environment.
-r|-rf) setup_testenv snap ;;
-R|-Rf) setup_testenv clone ;;
-f) setup_testenv ;;
esac
#
# According to different dataset type, create busy condition when try to
# destroy this dataset.
#
typeset mpt_dir
if [[ $opt == *f* ]]; then
"(pidlist: $pidlist)"
[[ -z $pidlist ]] && \
log_fail "Failure from mkbusy"
fi
;;
$VOL)
if [[ $opt == *f* ]]; then
"(pidlist: $pidlist)"
[[ -z $pidlist ]] && \
log_fail "Failure from mkbusy"
fi
;;
if [[ $opt == *f* ]]; then
"(pidlist: $pidlist)"
[[ -z $pidlist ]] && \
log_fail "Failure from mkbusy"
fi
;;
if [[ $opt == *f* ]]; then
[[ -z $pidlist ]] && \
log_fail "Failure from mkbusy"
fi
;;
esac
# Firstly, umount ufs filesystem which was created by zfs volume.
if is_global_zone; then
fi
# Invoke 'zfs destroy [-rRf] <dataset>'
# Kill any lingering instances of mkbusy, and clear the list.
pidlist=""
if [[ $opt == *R* ]]; then
fi
;;
if [[ $opt != -f ]]; then
fi
if [[ $opt == *R* ]]; then
fi
;;
if [[ $opt == *R* ]]; then
fi
;;
if [[ $opt == *R* ]]; then
fi
;;
if [[ $opt == *R* ]]; then
fi
;;
esac
}
log_assert "'zfs destroy -r|-R|-f|-rf|-Rf <fs|ctr|vol|snap>' should " \
"recursively destroy all children."
typeset dtst=""
typeset opt=""
typeset pidlist=""
done
done
log_pass "'zfs destroy -r|-R|-f|-rf|-Rf <fs|ctr|vol|snap>' passed."