1*2fae26bdSAlan Somers#! /usr/local/bin/ksh93 -p 2*2fae26bdSAlan Somers# 3*2fae26bdSAlan Somers# CDDL HEADER START 4*2fae26bdSAlan Somers# 5*2fae26bdSAlan Somers# The contents of this file are subject to the terms of the 6*2fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 7*2fae26bdSAlan Somers# You may not use this file except in compliance with the License. 8*2fae26bdSAlan Somers# 9*2fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*2fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 11*2fae26bdSAlan Somers# See the License for the specific language governing permissions 12*2fae26bdSAlan Somers# and limitations under the License. 13*2fae26bdSAlan Somers# 14*2fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 15*2fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*2fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 17*2fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 18*2fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 19*2fae26bdSAlan Somers# 20*2fae26bdSAlan Somers# CDDL HEADER END 21*2fae26bdSAlan Somers# 22*2fae26bdSAlan Somers 23*2fae26bdSAlan Somers# 24*2fae26bdSAlan Somers# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25*2fae26bdSAlan Somers# Use is subject to license terms. 26*2fae26bdSAlan Somers 27*2fae26bdSAlan Somers. $STF_SUITE/include/libtest.kshlib 28*2fae26bdSAlan Somers. $STF_SUITE/tests/reservation/reservation.kshlib 29*2fae26bdSAlan Somers 30*2fae26bdSAlan Somers############################################################################### 31*2fae26bdSAlan Somers# 32*2fae26bdSAlan Somers# __stc_assertion_start 33*2fae26bdSAlan Somers# 34*2fae26bdSAlan Somers# ID: reservation_003_pos 35*2fae26bdSAlan Somers# 36*2fae26bdSAlan Somers# DESCRIPTION: 37*2fae26bdSAlan Somers# 38*2fae26bdSAlan Somers# Verify that it's possible to set a reservation on a filesystem, 39*2fae26bdSAlan Somers# or volume multiple times, without resetting the reservation 40*2fae26bdSAlan Somers# to none. 41*2fae26bdSAlan Somers# 42*2fae26bdSAlan Somers# STRATEGY: 43*2fae26bdSAlan Somers# 1) Create a regular volume and a sparse volume 44*2fae26bdSAlan Somers# 2) Get the space available in the pool 45*2fae26bdSAlan Somers# 3) Set a reservation on the filesystem less than the space available. 46*2fae26bdSAlan Somers# 4) Verify that the 'reservation' property for the filesystem has 47*2fae26bdSAlan Somers# the correct value. 48*2fae26bdSAlan Somers# 5) Repeat 2-4 for different reservation values 49*2fae26bdSAlan Somers# 6) Repeat 3-5 for regular and sparse volume 50*2fae26bdSAlan Somers# 51*2fae26bdSAlan Somers# TESTABILITY: explicit 52*2fae26bdSAlan Somers# 53*2fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated 54*2fae26bdSAlan Somers# 55*2fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2005-07-19) 56*2fae26bdSAlan Somers# 57*2fae26bdSAlan Somers# __stc_assertion_end 58*2fae26bdSAlan Somers# 59*2fae26bdSAlan Somers################################################################################ 60*2fae26bdSAlan Somers 61*2fae26bdSAlan Somersverify_runnable "both" 62*2fae26bdSAlan Somers 63*2fae26bdSAlan Somerslog_assert "Verify it is possible to set reservations multiple times " \ 64*2fae26bdSAlan Somers "on a filesystem regular and sparse volume" 65*2fae26bdSAlan Somers 66*2fae26bdSAlan Somers 67*2fae26bdSAlan Somers# 68*2fae26bdSAlan Somers# Set a reservation $RESV_ITER times on a dataset and verify that 69*2fae26bdSAlan Somers# the reservation is correctly set each time. 70*2fae26bdSAlan Somers# 71*2fae26bdSAlan Somersfunction multiple_resv { #dataset 72*2fae26bdSAlan Somers typeset -i i=0 73*2fae26bdSAlan Somers 74*2fae26bdSAlan Somers dataset=$1 75*2fae26bdSAlan Somers 76*2fae26bdSAlan Somers log_must zero_reservation $dataset 77*2fae26bdSAlan Somers space_avail=`get_prop available $TESTPOOL` 78*2fae26bdSAlan Somers 79*2fae26bdSAlan Somers (( resv_size = ( space_avail - RESV_DELTA ) / RESV_ITER )) 80*2fae26bdSAlan Somers 81*2fae26bdSAlan Somers # 82*2fae26bdSAlan Somers # For regular (non-sparse) volumes the upper limit is determined 83*2fae26bdSAlan Somers # not by the space available in the pool but rather by the size 84*2fae26bdSAlan Somers # of the volume itself. 85*2fae26bdSAlan Somers # 86*2fae26bdSAlan Somers [[ $obj == $TESTPOOL/$TESTVOL ]] && \ 87*2fae26bdSAlan Somers (( resv_size = ( vol_set_size - RESV_DELTA ) / RESV_ITER )) 88*2fae26bdSAlan Somers 89*2fae26bdSAlan Somers resv_size_set=$resv_size 90*2fae26bdSAlan Somers 91*2fae26bdSAlan Somers while (( $i < $RESV_ITER )); do 92*2fae26bdSAlan Somers 93*2fae26bdSAlan Somers (( i = i + 1 )) 94*2fae26bdSAlan Somers 95*2fae26bdSAlan Somers (( resv_size_set = resv_size * i )) 96*2fae26bdSAlan Somers 97*2fae26bdSAlan Somers log_must $ZFS set reservation=$resv_size_set $dataset 98*2fae26bdSAlan Somers 99*2fae26bdSAlan Somers resv_size_get=`get_prop reservation $dataset` 100*2fae26bdSAlan Somers if [[ $resv_size_set != $resv_size_get ]]; then 101*2fae26bdSAlan Somers log_fail "Reservation not the expected value " \ 102*2fae26bdSAlan Somers "($resv_size_set != $resv_size_get)" 103*2fae26bdSAlan Somers fi 104*2fae26bdSAlan Somers done 105*2fae26bdSAlan Somers 106*2fae26bdSAlan Somers log_must zero_reservation $dataset 107*2fae26bdSAlan Somers} 108*2fae26bdSAlan Somers 109*2fae26bdSAlan Somersspace_avail=`get_prop available $TESTPOOL` 110*2fae26bdSAlan Somers 111*2fae26bdSAlan Somersif ! is_global_zone ; then 112*2fae26bdSAlan Somers OBJ_LIST="" 113*2fae26bdSAlan Somerselse 114*2fae26bdSAlan Somers OBJ_LIST="$TESTPOOL/$TESTVOL $TESTPOOL/$TESTVOL2" 115*2fae26bdSAlan Somers 116*2fae26bdSAlan Somers (( vol_set_size = space_avail / 4 )) 117*2fae26bdSAlan Somers vol_set_size=$(floor_volsize $vol_set_size) 118*2fae26bdSAlan Somers (( sparse_vol_set_size = space_avail * 4 )) 119*2fae26bdSAlan Somers sparse_vol_set_size=$(floor_volsize $sparse_vol_set_size) 120*2fae26bdSAlan Somers 121*2fae26bdSAlan Somers 122*2fae26bdSAlan Somers log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL 123*2fae26bdSAlan Somers log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL 124*2fae26bdSAlan Somers log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2 125*2fae26bdSAlan Somersfi 126*2fae26bdSAlan Somers 127*2fae26bdSAlan Somersfor obj in $TESTPOOL/$TESTFS $OBJ_LIST ; do 128*2fae26bdSAlan Somers multiple_resv $obj 129*2fae26bdSAlan Somersdone 130*2fae26bdSAlan Somers 131*2fae26bdSAlan Somerslog_pass "Multiple reservations successfully set on filesystem" \ 132*2fae26bdSAlan Somers " and both volume types" 133