24 # Use is subject to license terms.
25 #
26
27 #
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
29 #
30
31 . $STF_SUITE/tests/functional/reservation/reservation.cfg
32
33 #
34 # Function to set the reservation property of a dataset to
35 # 'none' and verify that it is correctly set using both the
36 # "normal" 'zfs get reservation' and the '-p' option which
37 # gives a numerical value.
38 #
39 function zero_reservation
40 {
41 typeset resv_val
42 dataset=$1
43
44 log_must $ZFS set reservation=none $dataset
45
46 resv_val=`$ZFS get -H reservation $dataset | awk '{print $3}'`
47 if [[ $? -ne 0 ]]; then
48 log_fail "Unable to get reservation prop on $dataset"
49 elif [[ $resv_val != "none" ]]; then
50 log_fail "Reservation not 'none' ($resv_val) as expected"
51 fi
52
53
54 resv_val=`$ZFS get -pH reservation $dataset | awk '{print $3}'`
55 if [[ $? -ne 0 ]]; then
56 log_fail "Unable to get reservation prop on $dataset"
57 elif [[ $resv_val -ne 0 ]]; then
58 log_fail "Reservation not 0 ($resv_val) as expected"
59 fi
60
61 return 0
62 }
63
64 #
65 # Utility function to see if two values are within a certain specified
66 # limit of each other. Used primarily to check that a dataset's parent
67 # is correctly accounting for space used/available. Need this function as
68 # currently there is some slop in the way space is accounted (i.e. can't
69 # do a direct comparison).
70 #
71 function within_limits
72 {
73 typeset -l valA=$1
74 typeset -l valB=$2
83 return 0
84 fi
85 fi
86
87 return 1
88 }
89
90 #
91 # Function to create and mount multiple filesystems. The filesystem
92 # will be named according to the name specified with a suffix value
93 # taken from the loop counter.
94 #
95 function create_multiple_fs # num_fs base_fs_name base_mnt_name
96 {
97 typeset -i iter=0
98 typeset -i count=$1
99 typeset FS_NAME=$2
100 typeset MNT_NAME=$3
101
102 while (($iter < $count)); do
103 log_must $ZFS create ${FS_NAME}$iter
104 log_must $ZFS set mountpoint=${MNT_NAME}$iter ${FS_NAME}$iter
105 ((iter = iter + 1))
106 done
107 }
108
109 #
110 # This function compute the largest volume size which is multiple of volume
111 # block size (default 8K) and not greater than the largest expected volsize.
112 #
113 # $1 The largest expected volume size.
114 # $2 The volume block size
115 #
116 function floor_volsize #<largest_volsize> [volblksize]
117 {
118 typeset -l largest_volsize=$1
119 typeset -l volblksize=${2:-8192}
120
121 if ((largest_volsize < volblksize)); then
122 log_fail "The largest_volsize must be greater than volblksize."
123 fi
124 typeset -l real_volsize
|
24 # Use is subject to license terms.
25 #
26
27 #
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
29 #
30
31 . $STF_SUITE/tests/functional/reservation/reservation.cfg
32
33 #
34 # Function to set the reservation property of a dataset to
35 # 'none' and verify that it is correctly set using both the
36 # "normal" 'zfs get reservation' and the '-p' option which
37 # gives a numerical value.
38 #
39 function zero_reservation
40 {
41 typeset resv_val
42 dataset=$1
43
44 log_must zfs set reservation=none $dataset
45
46 resv_val=`zfs get -H reservation $dataset | awk '{print $3}'`
47 if [[ $? -ne 0 ]]; then
48 log_fail "Unable to get reservation prop on $dataset"
49 elif [[ $resv_val != "none" ]]; then
50 log_fail "Reservation not 'none' ($resv_val) as expected"
51 fi
52
53
54 resv_val=`zfs get -pH reservation $dataset | awk '{print $3}'`
55 if [[ $? -ne 0 ]]; then
56 log_fail "Unable to get reservation prop on $dataset"
57 elif [[ $resv_val -ne 0 ]]; then
58 log_fail "Reservation not 0 ($resv_val) as expected"
59 fi
60
61 return 0
62 }
63
64 #
65 # Utility function to see if two values are within a certain specified
66 # limit of each other. Used primarily to check that a dataset's parent
67 # is correctly accounting for space used/available. Need this function as
68 # currently there is some slop in the way space is accounted (i.e. can't
69 # do a direct comparison).
70 #
71 function within_limits
72 {
73 typeset -l valA=$1
74 typeset -l valB=$2
83 return 0
84 fi
85 fi
86
87 return 1
88 }
89
90 #
91 # Function to create and mount multiple filesystems. The filesystem
92 # will be named according to the name specified with a suffix value
93 # taken from the loop counter.
94 #
95 function create_multiple_fs # num_fs base_fs_name base_mnt_name
96 {
97 typeset -i iter=0
98 typeset -i count=$1
99 typeset FS_NAME=$2
100 typeset MNT_NAME=$3
101
102 while (($iter < $count)); do
103 log_must zfs create ${FS_NAME}$iter
104 log_must zfs set mountpoint=${MNT_NAME}$iter ${FS_NAME}$iter
105 ((iter = iter + 1))
106 done
107 }
108
109 #
110 # This function compute the largest volume size which is multiple of volume
111 # block size (default 8K) and not greater than the largest expected volsize.
112 #
113 # $1 The largest expected volume size.
114 # $2 The volume block size
115 #
116 function floor_volsize #<largest_volsize> [volblksize]
117 {
118 typeset -l largest_volsize=$1
119 typeset -l volblksize=${2:-8192}
120
121 if ((largest_volsize < volblksize)); then
122 log_fail "The largest_volsize must be greater than volblksize."
123 fi
124 typeset -l real_volsize
|