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. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/reservation/reservation.kshlib 29 30############################################################################### 31# 32# __stc_assertion_start 33# 34# ID: reservation_004_pos 35# 36# DESCRIPTION: 37# 38# When a dataset which has a reservation set on it is destroyed, 39# the space consumed or reserved by that dataset should be released 40# back into the pool. 41# 42# STRATEGY: 43# 1) Create a filesystem, regular and sparse volume 44# 2) Get the space used and available in the pool 45# 3) Set a reservation on the filesystem less than the space available. 46# 4) Verify that the 'reservation' property for the filesystem has 47# the correct value. 48# 5) Destroy the filesystem without resetting the reservation value. 49# 6) Verify that the space used and available totals for the pool have 50# changed by the expected amounts (within tolerances). 51# 7) Repeat steps 3-6 for a regular volume and sparse volume 52# 53# TESTABILITY: explicit 54# 55# TEST_AUTOMATION_LEVEL: automated 56# 57# CODING_STATUS: COMPLETED (2005-07-19) 58# 59# __stc_assertion_end 60# 61################################################################################ 62 63verify_runnable "both" 64 65log_assert "Verify space released when a dataset with reservation is destroyed" 66 67log_must $ZFS create $TESTPOOL/$TESTFS2 68 69space_avail=`get_prop available $TESTPOOL` 70 71if ! is_global_zone ; then 72 OBJ_LIST="$TESTPOOL/$TESTFS2" 73else 74 OBJ_LIST="$TESTPOOL/$TESTFS2 \ 75 $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 log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL 83 if fs_prop_exist refreserv; then 84 log_must $ZFS set refreservation=none $TESTPOOL/$TESTVOL 85 fi 86 log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL 87 log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2 88fi 89 90# re-calculate space available. 91space_avail=`get_prop available $TESTPOOL` 92 93# Calculate a large but valid reservation value. 94resv_size_set=`expr $space_avail - $RESV_DELTA` 95 96for obj in $OBJ_LIST ; do 97 98 space_avail=`get_prop available $TESTPOOL` 99 space_used=`get_prop used $TESTPOOL` 100 101 # 102 # For regular (non-sparse) volumes the upper limit is determined 103 # not by the space available in the pool but rather by the size 104 # of the volume itself. 105 # 106 [[ $obj == $TESTPOOL/$TESTVOL ]] && \ 107 (( resv_size_set = vol_set_size - RESV_DELTA )) 108 109 log_must $ZFS set reservation=$resv_size_set $obj 110 111 resv_size_get=`get_prop reservation $obj` 112 if [[ $resv_size_set != $resv_size_get ]]; then 113 log_fail "Reservation not the expected value " \ 114 "($resv_size_set != $resv_size_get)" 115 fi 116 117 log_must $ZFS destroy -f $obj 118 119 new_space_avail=`get_prop available $TESTPOOL` 120 new_space_used=`get_prop used $TESTPOOL` 121 122 log_must within_limits $space_used $new_space_used $RESV_TOLERANCE 123 log_must within_limits $space_avail $new_space_avail $RESV_TOLERANCE 124done 125 126log_pass "Space correctly released when dataset is destroyed" 127