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 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)reservation_009_pos.ksh 1.3 09/08/06 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_009_pos 40# 41# DESCRIPTION: 42# 43# In pool with a full filesystem and another filesystem with a reservation 44# setting the reservation on the second filesystem to 'none' should allow more 45# data to be written to the first filesystem. 46# 47# 48# STRATEGY: 49# 1) Create a filesystem as a dataset 50# 2) Create a filesystem at the same level 51# 3) Set a reservation on the dataset filesystem 52# 4) Fill up the filesystem 53# 5) Set the reservation on the dataset filesystem to 'none' 54# 6) Verify we can write more data to the first filesystem 55# 56# TESTABILITY: explicit 57# 58# TEST_AUTOMATION_LEVEL: automated 59# 60# CODING_STATUS: COMPLETED (2005-07-04) 61# 62# __stc_assertion_end 63# 64################################################################################ 65 66verify_runnable "both" 67 68log_assert "Setting top level dataset reservation to 'none' allows more data to" \ 69 " be written to top level filesystem" 70 71log_must $ZFS create $TESTPOOL/$TESTFS1 72 73space_avail=`get_prop available $TESTPOOL` 74 75# 76# To make sure this test doesn't take too long to execute on 77# large pools, we calculate a reservation setting which when 78# applied to the dataset will ensure we have RESV_FREE_SPACE 79# left free in the pool which we can quickly fill. 80# 81(( resv_size_set = space_avail - RESV_FREE_SPACE )) 82 83log_must $ZFS set reservation=$resv_size_set $TESTPOOL/$TESTFS1 84 85space_avail_still=`get_prop available $TESTPOOL` 86 87fill_size=`expr $space_avail_still + $RESV_TOLERANCE` 88write_count=`expr $fill_size / $BLOCK_SIZE` 89 90# Now fill up the filesystem (which doesn't have a reservation set 91# and thus will use up whatever free space is left in the pool). 92$FILE_WRITE -o create -f $TESTDIR/$TESTFILE1 -b $BLOCK_SIZE \ 93 -c $write_count -d 0 94ret=$? 95if (( $ret != $ENOSPC )); then 96 log_fail "Did not get ENOSPC as expected (got $ret)." 97fi 98 99log_must $ZFS set reservation=none $TESTPOOL/$TESTFS1 100 101log_must $FILE_WRITE -o create -f $TESTDIR/$TESTFILE2 -b $BLOCK_SIZE \ 102 -c 1000 -d 0 103 104log_pass "Setting top level dataset reservation to 'none' allows more " \ 105 "data to be written to the top level filesystem" 106