26
26
#
27
27
28
28
#
29
- # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
29
+ # Copyright (c) 2012, 2018 by Delphix. All rights reserved.
30
30
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
31
31
#
32
32
43
43
# 1) Create 3 files
44
44
# 2) Create a pool backed by the files
45
45
# 3) Expand the files' size with truncate
46
- # 4) Use zpool online -e to online the vdevs
47
- # 5) Check that the pool size was expanded
46
+ # 4) Use zpool reopen to check the expandsize
47
+ # 5) Use zpool online -e to online the vdevs
48
+ # 6) Check that the pool size was expanded
48
49
#
49
50
50
51
verify_runnable " global"
@@ -64,8 +65,8 @@ log_onexit cleanup
64
65
65
66
log_assert " zpool can expand after zpool online -e zvol vdevs on LUN expansion"
66
67
67
-
68
68
for type in " " mirror raidz raidz2; do
69
+ # Initialize the file devices and the pool
69
70
for i in 1 2 3; do
70
71
log_must truncate -s $org_size ${TEMPFILE} .$i
71
72
done
@@ -80,13 +81,35 @@ for type in " " mirror raidz raidz2; do
80
81
" $autoexp "
81
82
fi
82
83
typeset prev_size=$( get_pool_prop size $TESTPOOL1 )
83
- typeset zfs_prev_size=$( zfs get -p avail $TESTPOOL1 | tail -1 | \
84
- awk ' {print $3}' )
84
+ typeset zfs_prev_size=$( get_prop avail $TESTPOOL1 )
85
85
86
+ # Increase the size of the file devices
86
87
for i in 1 2 3; do
87
88
log_must truncate -s $exp_size ${TEMPFILE} .$i
88
89
done
89
90
91
+ # Reopen the pool and check that the `expandsize` property is set
92
+ log_must zpool reopen $TESTPOOL1
93
+ typeset zpool_expandsize=$( get_pool_prop expandsize $TESTPOOL1 )
94
+
95
+ if [[ $type == " mirror" ]]; then
96
+ typeset expected_zpool_expandsize=$(( $exp_size - $org_size ))
97
+ else
98
+ typeset expected_zpool_expandsize=$(( 3 * ($exp_size - $org_size )) )
99
+ fi
100
+
101
+ if [[ " $zpool_expandsize " = " -" ]]; then
102
+ log_fail " pool $TESTPOOL1 did not detect any " \
103
+ " expandsize after reopen"
104
+ fi
105
+
106
+ if [[ $zpool_expandsize -ne $expected_zpool_expandsize ]]; then
107
+ log_fail " pool $TESTPOOL1 did not detect correct " \
108
+ " expandsize after reopen: found $zpool_expandsize ," \
109
+ " expected $expected_zpool_expandsize "
110
+ fi
111
+
112
+ # Online the devices to add the new space to the pool
90
113
for i in 1 2 3; do
91
114
log_must zpool online -e $TESTPOOL1 ${TEMPFILE} .$i
92
115
done
@@ -96,8 +119,7 @@ for type in " " mirror raidz raidz2; do
96
119
sync
97
120
98
121
typeset expand_size=$( get_pool_prop size $TESTPOOL1 )
99
- typeset zfs_expand_size=$( zfs get -p avail $TESTPOOL1 | tail -1 | \
100
- awk ' {print $3}' )
122
+ typeset zfs_expand_size=$( get_prop avail $TESTPOOL1 )
101
123
log_note " $TESTPOOL1 $type has previous size: $prev_size and " \
102
124
" expanded size: $expand_size "
103
125
@@ -112,8 +134,8 @@ for type in " " mirror raidz raidz2; do
112
134
grep " (+${expansion_size} " | wc -l)
113
135
114
136
if [[ $size_addition -ne $i ]]; then
115
- log_fail " pool $TESTPOOL1 is not autoexpand " \
116
- " after LUN expansion"
137
+ log_fail " pool $TESTPOOL1 did not expand " \
138
+ " after LUN expansion and zpool online -e "
117
139
fi
118
140
elif [[ $type == " mirror" ]]; then
119
141
typeset expansion_size=$(( $exp_size - $org_size ))
@@ -123,8 +145,8 @@ for type in " " mirror raidz raidz2; do
123
145
grep " (+${expansion_size} )" > /dev/null 2>&1
124
146
125
147
if [[ $? -ne 0 ]]; then
126
- log_fail " pool $TESTPOOL1 is not autoexpand " \
127
- " after LUN expansion"
148
+ log_fail " pool $TESTPOOL1 did not expand " \
149
+ " after LUN expansion and zpool online -e "
128
150
fi
129
151
else
130
152
typeset expansion_size=$(( 3 * ($exp_size - $org_size )) )
@@ -134,13 +156,13 @@ for type in " " mirror raidz raidz2; do
134
156
grep " (+${expansion_size} )" > /dev/null 2>&1
135
157
136
158
if [[ $? -ne 0 ]] ; then
137
- log_fail " pool $TESTPOOL1 is not autoexpand " \
138
- " after LUN expansion"
159
+ log_fail " pool $TESTPOOL1 did not expand " \
160
+ " after LUN expansion and zpool online -e "
139
161
fi
140
162
fi
141
163
else
142
- log_fail " pool $TESTPOOL1 is not autoexpanded after LUN " \
143
- " expansion "
164
+ log_fail " pool $TESTPOOL1 did not expand after LUN expansion " \
165
+ " and zpool online -e "
144
166
fi
145
167
log_must zpool destroy $TESTPOOL1
146
168
done
0 commit comments