1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016, 2019 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib 33 34# 35# DESCRIPTION: 36# User defined property are always inherited from its parent dataset 37# directly. 38# 39# STRATEGY: 40# 1. Create pool, fs, volume, fsclone & volclone. 41# 2. Get random user property name and set to the pool 42# 3. Verify all dataset user property inherit from pool. 43# 4. Set intermediate dataset and verify its children will inherit user 44# property from it directly. 45# 46 47verify_runnable "both" 48 49function cleanup 50{ 51 datasetexists $new_vol && log_must zfs rename $new_vol $vol 52 53 typeset dtst 54 for dtst in $new_fsclone $new_volclone $fsclone $volclone \ 55 $fssnap $volsnap; do 56 destroy_dataset "$dtst" "-f" 57 done 58 59 cleanup_user_prop $pool 60} 61 62# 63# Verify options datasets (3-n) inherit from the inherited dataset $2. 64# 65# $1 user property 66# $2 inherited dataset 67# $3-n datasets 68# 69function inherit_check 70{ 71 typeset prop=$1 72 typeset inherited_dtst=$2 73 shift 2 74 [[ -z $@ ]] && return 1 75 76 typeset inherited_value=$(get_prop $prop $inherited_dtst) 77 for dtst in $@; do 78 typeset value=$(get_prop $prop $dtst) 79 typeset source=$(get_source $prop $dtst) 80 if [[ "$value" != "$inherited_value" || \ 81 "$source" != "inherited from $inherited_dtst" ]] 82 then 83 return 1 84 fi 85 86 shift 87 done 88 89 return 0 90} 91 92log_assert "User defined property inherited from its parent." 93log_onexit cleanup 94 95pool=$TESTPOOL; fs=$pool/$TESTFS; vol=$pool/$TESTVOL 96fssnap=$fs@snap; volsnap=$vol@snap; 97log_must zfs snapshot $fssnap 98log_must zfs snapshot $volsnap 99fsclone=$pool/fsclone; volclone=$pool/volclone 100log_must zfs clone $fssnap $fsclone 101log_must zfs clone $volsnap $volclone 102 103prop_name=$(valid_user_property 10) 104value=$(user_property_value 16) 105log_must eval "zfs set $prop_name='$value' $pool" 106log_must eval "check_user_prop $pool $prop_name '$value'" 107log_must inherit_check $prop_name $pool $fs $vol $fsclone $volclone 108 109new_fsclone=$fs/fsclone; new_volclone=$fs/volclone 110log_must zfs rename $fsclone $new_fsclone 111log_must zfs rename $volclone $new_volclone 112log_must inherit_check $prop_name $pool $fs $new_fsclone $new_volclone 113 114log_note "Set intermediate dataset will change the inherited relationship." 115new_value=$(user_property_value 16) 116log_must eval "zfs set $prop_name='$new_value' $fs" 117log_must eval "check_user_prop $fs $prop_name '$new_value'" 118log_must inherit_check $prop_name $fs $new_fsclone $new_volclone 119 120log_pass "User defined property inherited from its parent passed." 121