12fae26bdSAlan Somers#! /usr/local/bin/ksh93 -p 22fae26bdSAlan Somers# 32fae26bdSAlan Somers# CDDL HEADER START 42fae26bdSAlan Somers# 52fae26bdSAlan Somers# The contents of this file are subject to the terms of the 62fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 72fae26bdSAlan Somers# You may not use this file except in compliance with the License. 82fae26bdSAlan Somers# 92fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 112fae26bdSAlan Somers# See the License for the specific language governing permissions 122fae26bdSAlan Somers# and limitations under the License. 132fae26bdSAlan Somers# 142fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 152fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 172fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 182fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 192fae26bdSAlan Somers# 202fae26bdSAlan Somers# CDDL HEADER END 212fae26bdSAlan Somers# 222fae26bdSAlan Somers 232fae26bdSAlan Somers# 242fae26bdSAlan Somers# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 252fae26bdSAlan Somers# Use is subject to license terms. 262fae26bdSAlan Somers 272fae26bdSAlan Somers. $STF_SUITE/include/libtest.kshlib 282fae26bdSAlan Somers. $STF_SUITE/tests/reservation/reservation.kshlib 292fae26bdSAlan Somers 302fae26bdSAlan Somers############################################################################### 312fae26bdSAlan Somers# 322fae26bdSAlan Somers# __stc_assertion_start 332fae26bdSAlan Somers# 342fae26bdSAlan Somers# ID: reservation_012_pos 352fae26bdSAlan Somers# 362fae26bdSAlan Somers# DESCRIPTION: 372fae26bdSAlan Somers# 382fae26bdSAlan Somers# A reservation guarantees a certain amount of space for a dataset. 392fae26bdSAlan Somers# Nothing else which happens in the same pool should affect that 402fae26bdSAlan Somers# space, i.e. even if the rest of the pool fills up the reserved 412fae26bdSAlan Somers# space should still be accessible. 422fae26bdSAlan Somers# 432fae26bdSAlan Somers# STRATEGY: 442fae26bdSAlan Somers# 1) Create 2 filesystems 452fae26bdSAlan Somers# 2) Set a reservation on one filesystem 462fae26bdSAlan Somers# 3) Fill up the other filesystem (which does not have a reservation 472fae26bdSAlan Somers# set) until all space is consumed 482fae26bdSAlan Somers# 4) Verify can still write to the filesystem which has a reservation 492fae26bdSAlan Somers# 502fae26bdSAlan Somers# TESTABILITY: explicit 512fae26bdSAlan Somers# 522fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated 532fae26bdSAlan Somers# 542fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2005-07-04) 552fae26bdSAlan Somers# 562fae26bdSAlan Somers# __stc_assertion_end 572fae26bdSAlan Somers# 582fae26bdSAlan Somers################################################################################ 592fae26bdSAlan Somers 602fae26bdSAlan Somersverify_runnable "both" 612fae26bdSAlan Somers 622fae26bdSAlan Somerslog_assert "Verify reservations protect space" 632fae26bdSAlan Somers 642fae26bdSAlan Somersfunction cleanup 652fae26bdSAlan Somers{ 662fae26bdSAlan Somers $ZFS destroy -f $TESTPOOL/$TESTFS2 672fae26bdSAlan Somers [[ -d $TESTDIR2 ]] && \ 682fae26bdSAlan Somers log_must $RM -rf $TESTDIR2 692fae26bdSAlan Somers} 702fae26bdSAlan Somers 712fae26bdSAlan Somerslog_onexit cleanup 722fae26bdSAlan Somers 732fae26bdSAlan Somerslog_must $ZFS create $TESTPOOL/$TESTFS2 742fae26bdSAlan Somerslog_must $ZFS set mountpoint=$TESTDIR2 $TESTPOOL/$TESTFS2 752fae26bdSAlan Somers 762fae26bdSAlan Somersspace_avail=`get_prop available $TESTPOOL` 772fae26bdSAlan Somers 782fae26bdSAlan Somers(( resv_size_set = space_avail - RESV_FREE_SPACE )) 792fae26bdSAlan Somers 802fae26bdSAlan Somerslog_must $ZFS set reservation=$resv_size_set $TESTPOOL/$TESTFS 812fae26bdSAlan Somers 822fae26bdSAlan Somers(( write_count = ( RESV_FREE_SPACE + RESV_TOLERANCE ) / BLOCK_SIZE )) 832fae26bdSAlan Somers 842fae26bdSAlan Somers$FILE_WRITE -o create -f $TESTDIR2/$TESTFILE1 -b $BLOCK_SIZE -c $write_count -d 0 852fae26bdSAlan Somersret=$? 862fae26bdSAlan Somersif [[ $ret != $ENOSPC ]]; then 872fae26bdSAlan Somers log_fail "Did not get ENOSPC (got $ret) for non-reserved filesystem" 882fae26bdSAlan Somersfi 892fae26bdSAlan Somers 902fae26bdSAlan Somers(( write_count = ( RESV_FREE_SPACE - RESV_TOLERANCE ) / BLOCK_SIZE )) 912fae26bdSAlan Somerslog_must $FILE_WRITE -o create -f $TESTDIR/$TESTFILE2 -b $BLOCK_SIZE -c $write_count -d 0 922fae26bdSAlan Somers 932fae26bdSAlan Somerslog_pass "Reserved space preserved correctly" 94