dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / refreserv / refreserv_002_pos.ksh
blobd4c0a4faebdc36121fc65c1638635d862ea286ea
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/refreserv/refreserv.cfg
36 # DESCRIPTION:
37 # Setting full size as refreservation, verify no snapshot can be created.
39 # STRATEGY:
40 # 1. Setting full size as refreservation on pool
41 # 2. Verify no snapshot can be created on this pool
42 # 3. Setting full size as refreservation on filesystem
43 # 4. Verify no snapshot can be created on it and its subfs
46 verify_runnable "both"
48 function cleanup
50 if is_global_zone ; then
51 log_must zfs set refreservation=none $TESTPOOL
53 if datasetexists $TESTPOOL@snap ; then
54 log_must zfs destroy -f $TESTPOOL@snap
57 log_must zfs destroy -rf $TESTPOOL/$TESTFS
58 log_must zfs create $TESTPOOL/$TESTFS
59 log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
62 # This function iteratively increases refreserv to its highest possible
63 # value. Simply setting refreserv == quota can allow enough writes to
64 # complete that the test fails.
65 function max_refreserv
67 typeset ds=$1
68 typeset -i incsize=131072
69 typeset -i rr=$(get_prop available $ds)
71 log_must zfs set refreserv=$rr $ds
72 while :; do
73 zfs set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1
74 if [[ $? == 0 ]]; then
75 ((rr += incsize))
76 continue
77 else
78 ((incsize /= 2))
79 ((incsize == 0)) && break
81 done
85 log_assert "Setting full size as refreservation, verify no snapshot " \
86 "can be created."
87 log_onexit cleanup
89 log_must zfs create $TESTPOOL/$TESTFS/subfs
91 typeset datasets
92 if is_global_zone; then
93 datasets="$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS/subfs"
94 else
95 datasets="$TESTPOOL/$TESTFS $TESTPOOL/$TESTFS/subfs"
98 for ds in $datasets; do
100 # Verify refreservation on dataset
102 log_must zfs set quota=25M $ds
103 max_refreserv $ds
104 log_mustnot zfs snapshot $ds@snap
105 if datasetexists $ds@snap ; then
106 log_fail "ERROR: $ds@snap should not exists."
109 log_must zfs set quota=none $ds
110 log_must zfs set refreservation=none $ds
111 done
113 log_pass "Setting full size as refreservation, verify no snapshot " \
114 "can be created."