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