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 http://www.opensolaris.org/os/licensing. 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 zfs inherit $prop $ds 71 if (($? !=0 )); then 72 log_fail "zfs inherit $prop $ds" 73 fi 74 done 75done 76if is_global_zone ; then 77 for prop in $(vol_inherit_prop) ; do 78 zfs inherit $prop $POOL/$FS/vol 79 if (($? !=0 )); then 80 log_fail "zfs inherit $prop $POOL/$FS/vol" 81 fi 82 done 83fi 84 85# 86# Verify datasets can be backup and restore correctly 87# Unmount $POOL/$FS to avoid two fs mount in the same mountpoint 88# 89log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-R" 90log_must zfs unmount -f $POOL/$FS 91log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-R" 92 93dstds=$(get_dst_ds $POOL $POOL2) 94# 95# Define all the POOL/POOL2 datasets pair 96# 97set -A pair "$POOL" "$dstds" \ 98 "$POOL/$FS" "$dstds/$FS" \ 99 "$POOL/$FS/fs1" "$dstds/$FS/fs1" \ 100 "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \ 101 "$POOL/pclone" "$dstds/pclone" \ 102 "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone" 103 104if is_global_zone ; then 105 typeset -i n=${#pair[@]} 106 pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol" 107 pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol" 108fi 109 110# 111# Verify all the sub-datasets can be properly received. 112# 113log_must cmp_ds_subs $POOL $dstds 114typeset -i i=0 115while ((i < ${#pair[@]})); do 116 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} 117 ((i += 2)) 118done 119 120log_pass "Changes made by 'zfs inherit' can be properly received." 121