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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)reservation_001_pos.ksh 1.3 08/02/27 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_001_pos 38# 39# DESCRIPTION: 40# 41# ZFS allows reservations to be set on filesystems and volumes, provided 42# the reservation is less than the space available in the pool. 43# 44# STRATEGY: 45# 1) Create a regular and sparse volume 46# (filesystem already created by default_setup) 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) Reset the reservation to 'none' 52# 6) Repeat steps 2-5 for both volume types 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 that to set a reservation on a filesystem" \ 67 " or volume must use value smaller than space" \ 68 " available property of pool" 69 70space_avail=`get_prop available $TESTPOOL` 71 72if ! is_global_zone ; then 73 OBJ_LIST="" 74else 75 OBJ_LIST="$TESTPOOL/$TESTVOL $TESTPOOL/$TESTVOL2" 76 77 (( vol_set_size = space_avail / 4 )) 78 vol_set_size=$(floor_volsize $vol_set_size) 79 (( sparse_vol_set_size = space_avail * 4 )) 80 sparse_vol_set_size=$(floor_volsize $sparse_vol_set_size) 81 82 # 83 # Note that when creating a regular volume we are implicitly 84 # setting a reservation upon it (i.e. the size of the volume) 85 # which we reset back to zero initially. 86 # 87 log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL 88 log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL 89 if fs_prop_exist refreserv; then 90 log_must $ZFS set refreservation=none $TESTPOOL/$TESTVOL 91 fi 92 log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2 93fi 94 95 96for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do 97 98 space_avail=`get_prop available $TESTPOOL` 99 resv_size_set=`expr $space_avail - $RESV_DELTA` 100 101 # 102 # For a regular (non-sparse) volume the upper limit 103 # for reservations is not determined by the space 104 # available in the pool but rather by the size of 105 # the volume itself. 106 # 107 [[ $obj == $TESTPOOL/$TESTVOL ]] && \ 108 (( resv_size_set = vol_set_size - RESV_DELTA )) 109 110 log_must $ZFS set reservation=$resv_size_set $obj 111 112 resv_size_get=`get_prop reservation $obj` 113 if [[ $resv_size_set != $resv_size_get ]]; then 114 log_fail "Reservation not the expected value "\ 115 "($resv_size_set != $resv_size_get)" 116 fi 117 118 log_must zero_reservation $obj 119 120 new_space_avail=`get_prop available $obj` 121 122 # 123 # Due to the way space is consumed and released by metadata we 124 # can't do an exact check here, but we do do a basic sanity 125 # check. 126 # 127 log_must within_limits $space_avail $new_space_avail $RESV_TOLERANCE 128done 129 130log_pass "Successfully set reservation on filesystem and volume" 131