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 datasetexists $ds && destroy_dataset $ds 53 done 54} 55 56log_assert "Verify 'copies' property with correct arguments works or not." 57log_onexit cleanup 58 59fs=$TESTPOOL/$TESTFS 60fs1=$TESTPOOL/$TESTFS1 61fs2=$TESTPOOL/$TESTFS2 62vol=$TESTPOOL/$TESTVOL 63vol1=$TESTPOOL/$TESTVOL1 64vol2=$TESTPOOL/$TESTVOL2 65 66# 67# Check the default value for copies property 68# 69for ds in $fs $vol; do 70 cmp_prop $ds 1 71done 72 73for val in 1 2 3; do 74 log_must zfs create -o copies=$val $fs1 75 if is_global_zone; then 76 log_must zfs create -V $VOLSIZE -o copies=$val $vol1 77 block_device_wait 78 else 79 log_must zfs create -o copies=$val $vol1 80 fi 81 for ds in $fs1 $vol1; do 82 cmp_prop $ds $val 83 done 84 85 for val2 in 3 2 1; do 86 log_must zfs create -o copies=$val2 $fs2 87 if is_global_zone; then 88 log_must zfs create -V $VOLSIZE -o copies=$val2 $vol2 89 block_device_wait 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 destroy_dataset $ds 96 block_device_wait 97 done 98 done 99 100 for ds in $fs1 $vol1; do 101 destroy_dataset $ds 102 block_device_wait 103 done 104 105done 106 107for val in 3 2 1; do 108 for ds in $fs $vol; do 109 log_must zfs set copies=$val $ds 110 cmp_prop $ds $val 111 done 112done 113 114log_pass "'copies' property with correct arguments works as expected. " 115