1 #!/usr/bin/bash -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 2007 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 28 # 29 # Copyright (c) 2013 by Delphix. All rights reserved. 30 # 31 32 . $STF_SUITE/include/libtest.shlib 33 . $STF_SUITE/tests/functional/reservation/reservation.shlib 34 35 # 36 # DESCRIPTION: 37 # 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. 41 # 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 49 # 50 51 verify_runnable "both" 52 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" 55 56 function cleanup 57 { 58 datasetexists $TESTPOOL/$TESTFS2 && \ 59 log_must $ZFS destroy -f $TESTPOOL/$TESTFS2 60 61 datasetexists $TESTPOOL/$TESTFS1 && \ 62 log_must $ZFS destroy -f $TESTPOOL/$TESTFS1 63 } 64 65 log_onexit cleanup 66 67 space_avail=`get_prop available $TESTPOOL` 68 space_used=`get_prop used $TESTPOOL` 69 70 resv_size_set=`expr $space_avail / 3` 71 72 # 73 # Function which creates two datasets, sets reservations on them, 74 # then destroys them and ensures that space is correctly accounted 75 # for. 76 # 77 # Any special arguments for create are passed in via the args 78 # paramater. 79 # 80 function create_resv_destroy { # args1 dataset1 args2 dataset2 81 82 args1=$1 83 dataset1=$2 84 args2=$3 85 dataset2=$4 86 87 log_must $ZFS create $args1 $dataset1 88 89 log_must $ZFS set reservation=$RESV_SIZE $dataset1 90 91 avail_aft_dset1=`get_prop available $TESTPOOL` 92 used_aft_dset1=`get_prop used $TESTPOOL` 93 94 log_must $ZFS create $args2 $dataset2 95 96 log_must $ZFS set reservation=$RESV_SIZE $dataset2 97 98 # 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. 102 # 103 log_must $ZFS destroy -f $dataset2 104 105 avail_dest_dset2=`get_prop available $TESTPOOL` 106 used_dest_dset2=`get_prop used $TESTPOOL` 107 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 110 111 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 116 117 avail_dest_dset1=`get_prop available $TESTPOOL` 118 used_dest_dset1=`get_prop used $TESTPOOL` 119 120 log_must within_limits $avail_dest_dset1 $space_avail $RESV_TOLERANCE 121 log_must within_limits $used_dest_dset1 $space_used $RESV_TOLERANCE 122 } 123 124 create_resv_destroy "" $TESTPOOL/$TESTFS1 "" $TESTPOOL/$TESTFS2 125 create_resv_destroy "" $TESTPOOL/$TESTFS2 "" $TESTPOOL/$TESTFS1 126 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"