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 2007 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_002_pos 35# 36# DESCRIPTION: 37# 38# Reservation values cannot exceed the amount of space available 39# in the pool. Verify that attempting to set a reservation greater 40# than this value fails. 41# 42# STRATEGY: 43# 1) Create a filesystem, regular and sparse volume 44# 2) Get the space available in the pool 45# 3) Attempt to set a reservation greater than the available space 46# on the filesystem and verify it fails. 47# 4) Verify that the reservation is still set to 'none' (or 0) on 48# the filesystem. 49# 5) Repeat 3-4 for regular and sparse volume 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2005-07-19) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61verify_runnable "both" 62 63log_assert "Reservation values cannot exceed the amount of space" \ 64 " available in the pool" 65 66space_avail=`get_prop available $TESTPOOL` 67 68if ! is_global_zone ; then 69 OBJ_LIST="" 70else 71 OBJ_LIST="$TESTPOOL/$TESTVOL $TESTPOOL/$TESTVOL2" 72 73 (( vol_set_size = space_avail / 4 )) 74 vol_set_size=$(floor_volsize $vol_set_size) 75 (( sparse_vol_set_size = space_avail * 4 )) 76 sparse_vol_set_size=$(floor_volsize $sparse_vol_set_size) 77 78 log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL 79 log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL 80 log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2 81fi 82 83for obj in $TESTPOOL/$TESTFS $OBJ_LIST ; do 84 85 space_avail=`get_prop available $TESTPOOL` 86 resv_size_set=`expr $space_avail + $RESV_DELTA` 87 88 # 89 # For regular (non-sparse) volumes the upper limit is determined 90 # not by the space available in the pool but rather by the size 91 # of the volume itself. 92 # 93 [[ $obj == $TESTPOOL/$TESTVOL ]] && \ 94 (( resv_size_set = vol_set_size + RESV_DELTA )) 95 96 log_must zero_reservation $obj 97 log_mustnot $ZFS set reservation=$resv_size_set $obj 98 99 resv_size_get=`get_prop reservation $obj` 100 101 if (( $resv_size_get != 0 )); then 102 log_fail "Reservation value non-zero ($resv_size_get)" 103 fi 104done 105 106log_pass "Attempting to set too large reservation failed as expected" 107