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