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_014_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_014_pos 40# 41# DESCRIPTION: 42# 43# A reservation cannot exceed the quota on a dataset 44# 45# STRATEGY: 46# 1) Create a filesystem and volume 47# 2) Set a quota on the filesystem 48# 3) Attempt to set a reservation larger than the quota. Verify 49# that the attempt fails. 50# 4) Repeat 2-3 for volume 51# 52# TESTABILITY: explicit 53# 54# TEST_AUTOMATION_LEVEL: automated 55# 56# CODING_STATUS: COMPLETED (2005-07-04) 57# 58# __stc_assertion_end 59# 60################################################################################ 61 62verify_runnable "both" 63 64log_assert "Verify cannot set reservation larger than quota" 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 79 log_must $ZFS create -V $vol_set_size $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 (( quota_set_size = space_avail / 3 )) 87 88 # 89 # A regular (non-sparse) volume's size is effectively 90 # its quota so only need to explicitly set quotas for 91 # filesystems and datasets. 92 # 93 # A volumes size is effectively its quota. The maximum 94 # reservation value that can be set on a volume is 95 # determined by the size of the volume or the amount of 96 # space in the pool, whichever is smaller. 97 # 98 if [[ $obj == $TESTPOOL/$TESTFS ]]; then 99 log_must $ZFS set quota=$quota_set_size $obj 100 (( resv_set_size = quota_set_size + RESV_SIZE )) 101 102 elif [[ $obj == $TESTPOOL/$TESTVOL2 ]] ; then 103 104 (( resv_set_size = sparse_vol_set_size + RESV_SIZE )) 105 106 elif [[ $obj == $TESTPOOL/$TESTVOL ]] ; then 107 108 (( resv_set_size = vol_set_size + RESV_SIZE )) 109 fi 110 111 orig_quota=`get_prop quota $obj` 112 113 log_mustnot $ZFS set reservation=$resv_set_size $obj 114 new_quota=`get_prop quota $obj` 115 116 if [[ $orig_quota != $new_quota ]]; then 117 log_fail "Quota value changed from $orig_quota " \ 118 "to $new_quota" 119 fi 120 121 if [[ $obj == $TESTPOOL/$TESTFS ]]; then 122 log_must $ZFS set quota=none $obj 123 fi 124done 125 126log_pass "As expected cannot set reservation larger than quota" 127