dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / reservation / reservation_007_pos.sh
blob2f4ff0132f938caa87bedc9d1525f29f4f3733a5
1 #!/usr/bin/bash -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 2007 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/reservation/reservation.shlib
36 # DESCRIPTION:
38 # Setting a reservation on dataset should have no effect on any other
39 # dataset at the same level in the hierarchy beyond using up available
40 # space in the pool.
42 # STRATEGY:
43 # 1) Create a filesystem
44 # 2) Set a reservation on the filesystem
45 # 3) Create another filesystem at the same level
46 # 4) Set a reservation on the second filesystem
47 # 5) Destroy both the filesystems
48 # 6) Verify space accounted for correctly
51 verify_runnable "both"
53 log_assert "Verify reservations on data sets doesn't affect other data sets " \
54 "at same level except for consuming space from common pool"
56 function cleanup
58 datasetexists $TESTPOOL/$TESTFS2 && \
59 log_must zfs destroy -f $TESTPOOL/$TESTFS2
61 datasetexists $TESTPOOL/$TESTFS1 && \
62 log_must zfs destroy -f $TESTPOOL/$TESTFS1
65 log_onexit cleanup
67 space_avail=`get_prop available $TESTPOOL`
68 space_used=`get_prop used $TESTPOOL`
70 resv_size_set=`expr $space_avail / 3`
73 # Function which creates two datasets, sets reservations on them,
74 # then destroys them and ensures that space is correctly accounted
75 # for.
77 # Any special arguments for create are passed in via the args
78 # paramater.
80 function create_resv_destroy { # args1 dataset1 args2 dataset2
82 args1=$1
83 dataset1=$2
84 args2=$3
85 dataset2=$4
87 log_must zfs create $args1 $dataset1
89 log_must zfs set reservation=$RESV_SIZE $dataset1
91 avail_aft_dset1=`get_prop available $TESTPOOL`
92 used_aft_dset1=`get_prop used $TESTPOOL`
94 log_must zfs create $args2 $dataset2
96 log_must zfs set reservation=$RESV_SIZE $dataset2
99 # After destroying the second dataset the space used and
100 # available totals should revert back to the values they
101 # had after creating the first dataset.
103 log_must zfs destroy -f $dataset2
105 avail_dest_dset2=`get_prop available $TESTPOOL`
106 used_dest_dset2=`get_prop used $TESTPOOL`
108 log_must within_limits $avail_aft_dset1 $avail_dest_dset2 $RESV_TOLERANCE
109 log_must within_limits $used_aft_dset1 $used_dest_dset2 $RESV_TOLERANCE
112 # After destroying the first dataset the space used and
113 # space available totals should revert back to the values
114 # they had when the pool was first created.
115 log_must zfs destroy -f $dataset1
117 avail_dest_dset1=`get_prop available $TESTPOOL`
118 used_dest_dset1=`get_prop used $TESTPOOL`
120 log_must within_limits $avail_dest_dset1 $space_avail $RESV_TOLERANCE
121 log_must within_limits $used_dest_dset1 $space_used $RESV_TOLERANCE
124 create_resv_destroy "" $TESTPOOL/$TESTFS1 "" $TESTPOOL/$TESTFS2
125 create_resv_destroy "" $TESTPOOL/$TESTFS2 "" $TESTPOOL/$TESTFS1
127 log_pass "Verify reservations on data sets doesn't affect other data sets at" \
128 " same level except for consuming space from common pool"