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# ident "@(#)reservation_003_pos.ksh 1.3 09/08/06 SMI" 28# 29 30. $STF_SUITE/include/libtest.kshlib 31. $STF_SUITE/tests/reservation/reservation.kshlib 32 33############################################################################### 34# 35# __stc_assertion_start 36# 37# ID: reservation_003_pos 38# 39# DESCRIPTION: 40# 41# Verify that it's possible to set a reservation on a filesystem, 42# or volume multiple times, without resetting the reservation 43# to none. 44# 45# STRATEGY: 46# 1) Create a regular volume and a sparse volume 47# 2) Get the space available in the pool 48# 3) Set a reservation on the filesystem less than the space available. 49# 4) Verify that the 'reservation' property for the filesystem has 50# the correct value. 51# 5) Repeat 2-4 for different reservation values 52# 6) Repeat 3-5 for regular and sparse volume 53# 54# TESTABILITY: explicit 55# 56# TEST_AUTOMATION_LEVEL: automated 57# 58# CODING_STATUS: COMPLETED (2005-07-19) 59# 60# __stc_assertion_end 61# 62################################################################################ 63 64verify_runnable "both" 65 66log_assert "Verify it is possible to set reservations multiple times " \ 67 "on a filesystem regular and sparse volume" 68 69 70# 71# Set a reservation $RESV_ITER times on a dataset and verify that 72# the reservation is correctly set each time. 73# 74function multiple_resv { #dataset 75 typeset -i i=0 76 77 dataset=$1 78 79 log_must zero_reservation $dataset 80 space_avail=`get_prop available $TESTPOOL` 81 82 (( resv_size = ( space_avail - RESV_DELTA ) / RESV_ITER )) 83 84 # 85 # For regular (non-sparse) volumes the upper limit is determined 86 # not by the space available in the pool but rather by the size 87 # of the volume itself. 88 # 89 [[ $obj == $TESTPOOL/$TESTVOL ]] && \ 90 (( resv_size = ( vol_set_size - RESV_DELTA ) / RESV_ITER )) 91 92 resv_size_set=$resv_size 93 94 while (( $i < $RESV_ITER )); do 95 96 (( i = i + 1 )) 97 98 (( resv_size_set = resv_size * i )) 99 100 log_must $ZFS set reservation=$resv_size_set $dataset 101 102 resv_size_get=`get_prop reservation $dataset` 103 if [[ $resv_size_set != $resv_size_get ]]; then 104 log_fail "Reservation not the expected value " \ 105 "($resv_size_set != $resv_size_get)" 106 fi 107 done 108 109 log_must zero_reservation $dataset 110} 111 112space_avail=`get_prop available $TESTPOOL` 113 114if ! is_global_zone ; then 115 OBJ_LIST="" 116else 117 OBJ_LIST="$TESTPOOL/$TESTVOL $TESTPOOL/$TESTVOL2" 118 119 (( vol_set_size = space_avail / 4 )) 120 vol_set_size=$(floor_volsize $vol_set_size) 121 (( sparse_vol_set_size = space_avail * 4 )) 122 sparse_vol_set_size=$(floor_volsize $sparse_vol_set_size) 123 124 125 log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL 126 log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL 127 log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2 128fi 129 130for obj in $TESTPOOL/$TESTFS $OBJ_LIST ; do 131 multiple_resv $obj 132done 133 134log_pass "Multiple reservations successfully set on filesystem" \ 135 " and both volume types" 136