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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib 34 35# 36# DESCRIPTION: 37# Verify "copies" property can be correctly set as 1,2 and 3 and different 38# filesystem can have different value of "copies" property within the same pool. 39# 40# STRATEGY: 41# 1. Create different filesystems with copies set as 1,2,3; 42# 2. Verify that the "copies" property has been set correctly 43# 44 45verify_runnable "both" 46 47function cleanup 48{ 49 typeset ds 50 51 for ds in $fs1 $fs2 $vol1 $vol2; do 52 if datasetexists $ds; then 53 log_must zfs destroy $ds 54 fi 55 done 56} 57 58log_assert "Verify 'copies' property with correct arguments works or not." 59log_onexit cleanup 60 61fs=$TESTPOOL/$TESTFS 62fs1=$TESTPOOL/$TESTFS1 63fs2=$TESTPOOL/$TESTFS2 64vol=$TESTPOOL/$TESTVOL 65vol1=$TESTPOOL/$TESTVOL1 66vol2=$TESTPOOL/$TESTVOL2 67 68# 69# Check the default value for copies property 70# 71for ds in $fs $vol; do 72 cmp_prop $ds 1 73done 74 75for val in 1 2 3; do 76 log_must zfs create -o copies=$val $fs1 77 if is_global_zone; then 78 log_must zfs create -V $VOLSIZE -o copies=$val $vol1 79 else 80 log_must zfs create -o copies=$val $vol1 81 fi 82 for ds in $fs1 $vol1; do 83 cmp_prop $ds $val 84 done 85 86 for val2 in 3 2 1; do 87 log_must zfs create -o copies=$val2 $fs2 88 if is_global_zone; then 89 log_must zfs create -V $VOLSIZE -o copies=$val2 $vol2 90 else 91 log_must zfs create -o copies=$val2 $vol2 92 fi 93 for ds in $fs2 $vol2; do 94 cmp_prop $ds $val2 95 log_must zfs destroy $ds 96 done 97 done 98 99 for ds in $fs1 $vol1; do 100 log_must zfs destroy $ds 101 done 102 103done 104 105for val in 3 2 1; do 106 for ds in $fs $vol; do 107 log_must zfs set copies=$val $ds 108 cmp_prop $ds $val 109 done 110done 111 112log_pass "'copies' property with correct arguments works as expected. " 113