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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)refreserv_002_pos.ksh 1.3 09/05/19 SMI" 28# 29 30. $STF_SUITE/include/libtest.kshlib 31 32################################################################################# 33# 34# __stc_assertion_start 35# 36# ID: refreserv_002_pos 37# 38# DESCRIPTION: 39# Setting full size as refreservation, verify no snapshot can be created. 40# 41# STRATEGY: 42# 1. Setting full size as refreservation on pool 43# 2. Verify no snapshot can be created on this pool 44# 3. Setting full size as refreservation on filesystem 45# 4. Verify no snapshot can be created on it and its subfs 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2007-11-05) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "both" 58 59function cleanup 60{ 61 if is_global_zone ; then 62 log_must $ZFS set refreservation=none $TESTPOOL 63 64 if datasetexists $TESTPOOL@snap ; then 65 log_must $ZFS destroy -f $TESTPOOL@snap 66 fi 67 fi 68 log_must $ZFS destroy -rf $TESTPOOL/$TESTFS 69 log_must $ZFS create $TESTPOOL/$TESTFS 70 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 71} 72 73# This function iteratively increases refreserv to its highest possible 74# value. Simply setting refreserv == quota can allow enough writes to 75# complete that the test fails. 76function max_refreserv 77{ 78 typeset ds=$1 79 typeset -i incsize=131072 80 typeset -i rr=$(get_prop available $ds) 81 82 log_must $ZFS set refreserv=$rr $ds 83 while :; do 84 $ZFS set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1 85 if [[ $? == 0 ]]; then 86 ((rr += incsize)) 87 continue 88 else 89 ((incsize /= 2)) 90 ((incsize == 0)) && break 91 fi 92 done 93} 94 95 96log_assert "Setting full size as refreservation, verify no snapshot " \ 97 "can be created." 98log_onexit cleanup 99 100log_must $ZFS create $TESTPOOL/$TESTFS/subfs 101 102typeset datasets 103if is_global_zone; then 104 datasets="$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS/subfs" 105else 106 datasets="$TESTPOOL/$TESTFS $TESTPOOL/$TESTFS/subfs" 107fi 108 109for ds in $datasets; do 110 # 111 # Verify refreservation on dataset 112 # 113 log_must $ZFS set quota=25M $ds 114 max_refreserv $ds 115 log_mustnot $ZFS snapshot $ds@snap 116 if datasetexists $ds@snap ; then 117 log_fail "ERROR: $ds@snap should not exists." 118 fi 119 120 log_must $ZFS set quota=none $ds 121 log_must $ZFS set refreservation=none $ds 122done 123 124log_pass "Setting full size as refreservation, verify no snapshot " \ 125 "can be created." 126