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 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)reservation_016_pos.ksh 1.2 07/01/09 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_016_pos 40# 41# DESCRIPTION: 42# 43# In pool with a full filesystem and a regular volume (with implicit 44# reservation) destroying the volume should allow more data to be written 45# to the filesystem 46# 47# 48# STRATEGY: 49# 1) Create a regular (non-sparse) volume 50# 2) Create a filesystem at the same level 51# 3) Fill up the filesystem 52# 4) Destroy the volume 53# 5) Verify can write more data to the filesystem 54# 55# TESTABILITY: explicit 56# 57# TEST_AUTOMATION_LEVEL: automated 58# 59# CODING_STATUS: COMPLETED (2005-07-19) 60# 61# __stc_assertion_end 62# 63################################################################################ 64 65verify_runnable "global" 66 67log_assert "Destroying a regular volume with reservation allows more data to" \ 68 " be written to top level filesystem" 69 70space_avail=`get_prop available $TESTPOOL` 71 72# 73# To make sure this test doesn't take too long to execute on 74# large pools, we calculate a volume size which will ensure we 75# have RESV_FREE_SPACE left free in the pool. 76# 77(( vol_set_size = space_avail * 95 / 100 )) 78vol_set_size=$(floor_volsize $vol_set_size $BLOCK_SIZE) 79 80# Creating a regular volume implicitly sets its reservation 81# property to the same value. 82log_must $ZFS create -b $BLOCK_SIZE -V $vol_set_size $TESTPOOL/$TESTVOL 83 84space_avail_still=`get_prop available $TESTPOOL` 85 86# Create a secondary filesystem to soak up what's left to get 87# to RESV_FREE_SPACE for the pool. 88space_avail_still=`get_prop available $TESTPOOL` 89(( zfs_res = space_avail_still - RESV_FREE_SPACE )) 90log_must $ZFS create -o refreservation=$zfs_res $TESTPOOL/$TESTFS2 91 92space_avail_still=`get_prop available $TESTPOOL` 93 94fill_size=`expr $space_avail_still + $RESV_TOLERANCE` 95write_count=`expr $fill_size / $BLOCK_SIZE` 96 97# Now fill up the filesystem (which doesn't have a reservation set 98# and thus will use up whatever free space is left in the pool). 99$FILE_WRITE -o create -f $TESTDIR/$TESTFILE1 -b $BLOCK_SIZE \ 100 -c $write_count -d 0 101ret=$? 102if (( $ret != $ENOSPC )); then 103 log_fail "Did not get ENOSPC as expected (got $ret)." 104fi 105 106log_must $ZFS destroy -f $TESTPOOL/$TESTVOL 107 108log_must $FILE_WRITE -o create -f $TESTDIR/$TESTFILE2 -b $BLOCK_SIZE \ 109 -c 1000 -d 0 110 111log_pass "Destroying volume with reservation allows more data to" \ 112 " be written to top level filesystem" 113