1 #! /usr/local/bin/ksh93 -p
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.
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.
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]
26 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ident "@(#)reservation_005_pos.ksh 1.2 07/01/09 SMI"
32 . $STF_SUITE/include/libtest.kshlib
33 . $STF_SUITE/tests/reservation/reservation.kshlib
35 ###############################################################################
37 # __stc_assertion_start
39 # ID: reservation_005_pos
43 # When a reservation property of a filesystem, regular volume
44 # or sparse volume is set to 'none' the space previously consumed by the
45 # reservation should be released back to the pool
48 # 1) Create a filesystem, regular volume and sparse volume
49 # 2) Get the space used and available in the pool
50 # 3) Set a reservation on the filesystem less than the space available.
51 # 4) Verify that the 'reservation' property for the filesystem has
53 # 5) Reset the reservation value back to zero (or 'none')
54 # 6) Verify that the space used and available totals for the pool have
55 # changed by the expected amounts (within tolerances).
56 # 7) Repeat steps 3-6 for a regular volume, sparse volume
58 # TESTABILITY: explicit
60 # TEST_AUTOMATION_LEVEL: automated
62 # CODING_STATUS: COMPLETED (2005-07-04)
66 ################################################################################
68 verify_runnable "both"
70 log_assert "Verify space released when reservation on a dataset is set "\
73 space_avail=`get_prop available $TESTPOOL`
75 if ! is_global_zone ; then
78 OBJ_LIST="$TESTPOOL/$TESTVOL $TESTPOOL/$TESTVOL2"
79 (( vol_set_size = space_avail / 4 ))
80 vol_set_size=$(floor_volsize $vol_set_size)
81 (( sparse_vol_set_size = space_avail * 4 ))
82 sparse_vol_set_size=$(floor_volsize $sparse_vol_set_size)
85 log_must $ZFS create -V $vol_set_size $TESTPOOL/$TESTVOL
86 log_must $ZFS set reservation=none $TESTPOOL/$TESTVOL
87 log_must $ZFS create -s -V $sparse_vol_set_size $TESTPOOL/$TESTVOL2
90 space_avail=`get_prop available $TESTPOOL`
91 space_used=`get_prop used $TESTPOOL`
93 # Calculate a large but valid reservation value.
94 resv_size_set=`expr $space_avail - $RESV_DELTA`
96 for obj in $TESTPOOL/$TESTFS $OBJ_LIST ; do
99 # For regular (non-sparse) volumes the upper limit is determined
100 # not by the space available in the pool but rather by the size
101 # of the volume itself.
103 [[ $obj == $TESTPOOL/$TESTVOL ]] && \
104 (( resv_size_set = vol_set_size - RESV_DELTA ))
106 log_must $ZFS set reservation=$resv_size_set $obj
108 resv_size_get=`get_prop reservation $obj`
109 if [[ $resv_size_set != $resv_size_get ]]; then
110 log_fail "Reservation not the expected value "\
111 "($resv_size_set != $resv_size_get)"
114 log_must $ZFS set reservation=none $obj
116 new_space_avail=`get_prop available $TESTPOOL`
117 new_space_used=`get_prop used $TESTPOOL`
119 log_must within_limits $space_used $new_space_used $RESV_TOLERANCE
120 log_must within_limits $space_avail $new_space_avail $RESV_TOLERANCE
123 log_pass "Space correctly released when dataset reservation set to 'none'"