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