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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/rsend/rsend.kshlib 33 34# 35# DESCRIPTION: 36# Changes made by 'zfs inherit' can be properly received. 37# 38# STRATEGY: 39# 1. Inherit property for filesystem and volume 40# 2. Send and restore them in the target pool 41# 3. Verify all the datasets can be properly backup and receive 42# 43 44verify_runnable "both" 45 46function cleanup 47{ 48 log_must cleanup_pool $POOL 49 log_must cleanup_pool $POOL2 50 51 log_must setup_test_model $POOL 52} 53 54log_assert "Verify changes made by 'zfs inherit' can be properly received." 55log_onexit cleanup 56 57# 58# Setting all the $FS properties as local value, 59# 60for prop in $(fs_inherit_prop); do 61 value=$(get_prop $prop $POOL/$FS) 62 log_must zfs set $prop=$value $POOL/$FS 63done 64 65# 66# Inherit properties in sub-datasets 67# 68for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone"; do 69 for prop in $(fs_inherit_prop); do 70 log_must zfs inherit $prop $ds 71 done 72done 73if is_global_zone; then 74 for prop in $(vol_inherit_prop); do 75 log_must zfs inherit $prop $POOL/$FS/vol 76 done 77fi 78 79# 80# Verify datasets can be backup and restore correctly 81# Unmount $POOL/$FS to avoid two fs mount in the same mountpoint 82# 83log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-R" 84log_must zfs unmount -f $POOL/$FS 85log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-R" 86 87dstds=$(get_dst_ds $POOL $POOL2) 88# 89# Define all the POOL/POOL2 datasets pair 90# 91set -A pair "$POOL" "$dstds" \ 92 "$POOL/$FS" "$dstds/$FS" \ 93 "$POOL/$FS/fs1" "$dstds/$FS/fs1" \ 94 "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \ 95 "$POOL/pclone" "$dstds/pclone" \ 96 "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone" 97 98if is_global_zone ; then 99 typeset -i n=${#pair[@]} 100 pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol" 101 pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol" 102fi 103 104# 105# Verify all the sub-datasets can be properly received. 106# 107log_must cmp_ds_subs $POOL $dstds 108typeset -i i=0 109while ((i < ${#pair[@]})); do 110 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} 111 ((i += 2)) 112done 113 114log_pass "Changes made by 'zfs inherit' can be properly received." 115