1#! /usr/local/bin/ksh93 -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. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/reservation/reservation.kshlib 29 30############################################################################### 31# 32# __stc_assertion_start 33# 34# ID: reservation_017_pos 35# 36# DESCRIPTION: 37# 38# For a sparse volume changes to the volsize are not reflected in the reservation 39# 40# STRATEGY: 41# 1) Create a regular and sparse volume 42# 2) Get the space available in the pool 43# 3) Set reservation with various size on the regular and sparse volume 44# 4) Verify that the 'reservation' property for the regular volume has 45# the correct value. 46# 5) Verify that the 'reservation' property for the sparse volume is set to 'none' 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2006-08-17) 53# 54# __stc_assertion_end 55# 56############################################################################### 57 58verify_runnable "global" 59 60log_assert "Verify that the volsize changes of sparse volume are not reflected" \ 61 "in the reservation" 62 63#Create a regular and sparse volume for testing. 64regvol=$TESTPOOL/$TESTVOL 65sparsevol=$TESTPOOL/$TESTVOL2 66log_must $ZFS create -V $VOLSIZE -o volblocksize=16k $regvol 67log_must $ZFS create -s -V $VOLSIZE -o volblocksize=16k $sparsevol 68 69typeset -l vsize=$(get_prop available $TESTPOOL) 70typeset -i iterate=10 71typeset -l regreserv 72typeset -l sparsereserv 73typeset -l vblksize1=$(get_prop volblocksize $regvol) 74typeset -l vblksize2=$(get_prop volblocksize $sparsevol) 75typeset -l blknum=0 76if [ "$vblksize1" != "$vblksize2" ]; then 77 log_must $ZFS set volblocksize=$vblksize1 $sparsevol 78fi 79(( blknum = vsize / vblksize1 )) 80 81typeset -i randomblknum 82while (( iterate > 1 )); do 83 (( randomblknum = 1 + $RANDOM % $blknum )) 84 #Make sure volsize is a multiple of volume block size 85 (( vsize = $randomblknum * $vblksize1 )) 86 log_must $ZFS set volsize=$vsize $regvol 87 log_must $ZFS set volsize=$vsize $sparsevol 88 regreserv=$(get_prop refreservation $regvol) 89 sparsereserv=$(get_prop refreservation $sparsevol) 90 reg_shouldreserv=$(zvol_volsize_to_reservation $vsize $vblksize1 1) 91 92 (( $sparsereserv == $vsize )) && \ 93 log_fail "volsize changes of sparse volume is reflected in reservation." 94 (( $regreserv != $reg_shouldreserv )) && \ 95 log_fail "volsize changes of regular volume isnot reflected in reservation." 96 97 (( iterate = iterate - 1 )) 98done 99 100log_pass "The volsize change of sparse volume is not reflected in reservation as expected." 101