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.
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.
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]
24 # Copyright (c) 2009, Sun Microsystems Inc. All rights reserved.
25 # Copyright (c) 2013, 2016, Delphix. All rights reserved.
26 # Use is subject to license terms.
29 . $STF_SUITE/include/properties.shlib
30 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
34 # zfs send -R will backup all the filesystem properties correctly.
37 # 1. Setting properties for all the filesystem and volumes randomly
38 # 2. Backup all the data from POOL by send -R
39 # 3. Restore all the data in POOL2
40 # 4. Verify all the properties in the two pools are the same
43 verify_runnable "global"
49 typeset backfile=$TESTDIR/edited_prop_$ds
53 typeset props=$(zfs inherit 2>&1 | \
54 awk '$2=="YES" {print $1}' | \
55 egrep -v "^vol|\.\.\.$")
56 for item in $props ; do
57 if [[ $item == "mlslabel" ]] && \
58 ! is_te_enabled ; then
61 zfs get -H -o property,value $item $ds >> \
64 log_fail "zfs get -H -o property,value"\
65 "$item $ds > $backfile"
70 if [[ ! -f $backfile ]] ; then
71 log_fail "$ds need backup properties firstly."
75 while read prop value ; do
76 eval zfs set $prop='$value' $ds
78 log_fail "zfs set $prop=$value $ds"
83 log_fail "Unrecognized behaviour: $behaviour"
89 log_must cleanup_pool $POOL
90 log_must cleanup_pool $POOL2
92 log_must edited_prop "set" $POOL
93 log_must edited_prop "set" $POOL2
96 for prop in $(fs_inherit_prop) ; do
97 log_must zfs inherit $prop $POOL
98 log_must zfs inherit $prop $POOL2
101 log_must setup_test_model $POOL
103 if [[ -d $TESTDIR ]]; then
104 log_must rm -rf $TESTDIR/*
108 log_assert "Verify zfs send -R will backup all the filesystem properties " \
112 log_must edited_prop "get" $POOL
113 log_must edited_prop "get" $POOL2
115 for fs in "$POOL" "$POOL/pclone" "$POOL/$FS" "$POOL/$FS/fs1" \
116 "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do
117 rand_set_prop $fs aclinherit "discard" "noallow" "secure" "passthrough"
118 rand_set_prop $fs checksum "on" "off" "fletcher2" "fletcher4" "sha256"
119 rand_set_prop $fs acltype "off" "posix" "nfsv4" "noacl" "posixacl"
120 rand_set_prop $fs atime "on" "off"
121 rand_set_prop $fs checksum "on" "off" "fletcher2" "fletcher4" "sha256"
122 rand_set_prop $fs compression "${compress_prop_vals[@]}"
123 rand_set_prop $fs copies "1" "2" "3"
124 rand_set_prop $fs devices "on" "off"
125 rand_set_prop $fs exec "on" "off"
126 rand_set_prop $fs quota "512M" "1024M"
127 rand_set_prop $fs recordsize "512" "2K" "8K" "32K" "128K"
128 rand_set_prop $fs dnodesize "legacy" "auto" "1k" "2k" "4k" "8k" "16k"
129 rand_set_prop $fs setuid "on" "off"
130 rand_set_prop $fs snapdir "hidden" "visible"
131 if ! is_freebsd; then
132 rand_set_prop $fs xattr "on" "off"
134 rand_set_prop $fs user:prop "aaa" "bbb" "23421" "()-+?"
137 for vol in "$POOL/vol" "$POOL/$FS/vol" ; do
138 rand_set_prop $vol checksum "on" "off" "fletcher2" "fletcher4" "sha256"
139 rand_set_prop $vol compression "${compress_prop_vals[@]}"
140 rand_set_prop $vol readonly "on" "off"
141 rand_set_prop $vol copies "1" "2" "3"
142 rand_set_prop $vol user:prop "aaa" "bbb" "23421" "()-+?"
146 # Verify inherited property can be received
147 rand_set_prop $POOL redundant_metadata "all" "most"
148 rand_set_prop $POOL sync "standard" "always" "disabled"
151 # Duplicate POOL2 for testing
153 log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-final-R"
154 log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-final-R"
157 # Define all the POOL/POOL2 datasets pair
159 set -A pair "$POOL" "$POOL2" \
160 "$POOL/$FS" "$POOL2/$FS" \
161 "$POOL/$FS/fs1" "$POOL2/$FS/fs1" \
162 "$POOL/$FS/fs1/fs2" "$POOL2/$FS/fs1/fs2" \
163 "$POOL/pclone" "$POOL2/pclone" \
164 "$POOL/$FS/fs1/fclone" "$POOL2/$FS/fs1/fclone" \
165 "$POOL/vol" "$POOL2/vol" \
166 "$POOL/$FS/vol" "$POOL2/$FS/vol"
169 while ((i < ${#pair[@]})); do
170 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]}
176 zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1
177 if (( $? == 0 )) ; then
179 while ((i < ${#pair[@]})); do
180 log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final
185 log_pass "Verify zfs send -R will backup all the filesystem properties " \