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