]> git.proxmox.com Git - zfsonlinux.git/blob - zfs-patches/0035-Revert-zpool-reopen-should-detect-expanded-devices.patch
update/rebase to zfs-0.7.11 with patches from ZOL
[zfsonlinux.git] / zfs-patches / 0035-Revert-zpool-reopen-should-detect-expanded-devices.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Tony Hutter <hutter2@llnl.gov>
3 Date: Thu, 13 Sep 2018 10:11:42 -0700
4 Subject: [PATCH] Revert "zpool reopen should detect expanded devices"
5
6 This reverts commit 2a16d4cfaf791ba2a6f61b29d1e3f2e7b675f913.
7
8 The commit was causing a "attempt to access beyond the end
9 of device" error:
10
11 list.zfsonlinux.org/pipermail/zfs-discuss/2018-September/032217.html
12
13 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
14 ---
15 include/sys/vdev_disk.h | 12 -----
16 lib/libefi/rdwr_efi.c | 20 +-------
17 lib/libzfs/libzfs_pool.c | 14 +++++-
18 module/zfs/vdev.c | 3 +-
19 module/zfs/vdev_disk.c | 44 ++++--------------
20 .../cli_root/zpool_expand/zpool_expand_002_pos.ksh | 54 +++++++---------------
21 6 files changed, 41 insertions(+), 106 deletions(-)
22
23 diff --git a/include/sys/vdev_disk.h b/include/sys/vdev_disk.h
24 index b8a32b316..15570b105 100644
25 --- a/include/sys/vdev_disk.h
26 +++ b/include/sys/vdev_disk.h
27 @@ -23,23 +23,11 @@
28 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
29 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
30 * LLNL-CODE-403049.
31 - * Copyright (c) 2018 by Delphix. All rights reserved.
32 */
33
34 #ifndef _SYS_VDEV_DISK_H
35 #define _SYS_VDEV_DISK_H
36
37 -/*
38 - * Don't start the slice at the default block of 34; many storage
39 - * devices will use a stripe width of 128k, other vendors prefer a 1m
40 - * alignment. It is best to play it safe and ensure a 1m alignment
41 - * given 512B blocks. When the block size is larger by a power of 2
42 - * we will still be 1m aligned. Some devices are sensitive to the
43 - * partition ending alignment as well.
44 - */
45 -#define NEW_START_BLOCK 2048
46 -#define PARTITION_END_ALIGNMENT 2048
47 -
48 #ifdef _KERNEL
49 #include <sys/vdev.h>
50
51 diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c
52 index 19cb17e5a..7935047eb 100644
53 --- a/lib/libefi/rdwr_efi.c
54 +++ b/lib/libefi/rdwr_efi.c
55 @@ -22,7 +22,6 @@
56 /*
57 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
58 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
59 - * Copyright (c) 2018 by Delphix. All rights reserved.
60 */
61
62 #include <stdio.h>
63 @@ -1154,7 +1153,7 @@ efi_use_whole_disk(int fd)
64
65 /*
66 * Find the last physically non-zero partition.
67 - * This should be the reserved partition.
68 + * This is the reserved partition.
69 */
70 for (i = 0; i < efi_label->efi_nparts; i ++) {
71 if (resv_start < efi_label->efi_parts[i].p_start) {
72 @@ -1164,23 +1163,6 @@ efi_use_whole_disk(int fd)
73 }
74
75 /*
76 - * Verify that we've found the reserved partition by checking
77 - * that it looks the way it did when we created it in zpool_label_disk.
78 - * If we've found the incorrect partition, then we know that this
79 - * device was reformatted and no longer is soley used by ZFS.
80 - */
81 - if ((efi_label->efi_parts[resv_index].p_size != EFI_MIN_RESV_SIZE) ||
82 - (efi_label->efi_parts[resv_index].p_tag != V_RESERVED) ||
83 - (resv_index != 8)) {
84 - if (efi_debug) {
85 - (void) fprintf(stderr,
86 - "efi_use_whole_disk: wholedisk not available\n");
87 - }
88 - efi_free(efi_label);
89 - return (VT_ENOSPC);
90 - }
91 -
92 - /*
93 * Find the last physically non-zero partition before that.
94 * This is the data partition.
95 */
96 diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c
97 index 315ba954c..76228d573 100644
98 --- a/lib/libzfs/libzfs_pool.c
99 +++ b/lib/libzfs/libzfs_pool.c
100 @@ -22,7 +22,7 @@
101 /*
102 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
103 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
104 - * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
105 + * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
106 * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
107 * Copyright (c) 2017 Datto Inc.
108 */
109 @@ -42,7 +42,6 @@
110 #include <sys/efi_partition.h>
111 #include <sys/vtoc.h>
112 #include <sys/zfs_ioctl.h>
113 -#include <sys/vdev_disk.h>
114 #include <dlfcn.h>
115
116 #include "zfs_namecheck.h"
117 @@ -936,6 +935,17 @@ zpool_prop_get_feature(zpool_handle_t *zhp, const char *propname, char *buf,
118 }
119
120 /*
121 + * Don't start the slice at the default block of 34; many storage
122 + * devices will use a stripe width of 128k, other vendors prefer a 1m
123 + * alignment. It is best to play it safe and ensure a 1m alignment
124 + * given 512B blocks. When the block size is larger by a power of 2
125 + * we will still be 1m aligned. Some devices are sensitive to the
126 + * partition ending alignment as well.
127 + */
128 +#define NEW_START_BLOCK 2048
129 +#define PARTITION_END_ALIGNMENT 2048
130 +
131 +/*
132 * Validate the given pool name, optionally putting an extended error message in
133 * 'buf'.
134 */
135 diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c
136 index b643bd354..acac2a973 100644
137 --- a/module/zfs/vdev.c
138 +++ b/module/zfs/vdev.c
139 @@ -21,7 +21,7 @@
140
141 /*
142 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
143 - * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
144 + * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
145 * Copyright 2017 Nexenta Systems, Inc.
146 * Copyright (c) 2014 Integros [integros.com]
147 * Copyright 2016 Toomas Soome <tsoome@me.com>
148 @@ -3039,6 +3039,7 @@ vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
149 vd->vdev_max_asize - vd->vdev_asize,
150 1ULL << tvd->vdev_ms_shift);
151 }
152 + vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize;
153 if (vd->vdev_aux == NULL && vd == vd->vdev_top &&
154 !vd->vdev_ishole) {
155 vs->vs_fragmentation = vd->vdev_mg->mg_fragmentation;
156 diff --git a/module/zfs/vdev_disk.c b/module/zfs/vdev_disk.c
157 index c5708cb2b..46fc120fb 100644
158 --- a/module/zfs/vdev_disk.c
159 +++ b/module/zfs/vdev_disk.c
160 @@ -23,7 +23,7 @@
161 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
162 * Rewritten for Linux by Brian Behlendorf <behlendorf1@llnl.gov>.
163 * LLNL-CODE-403049.
164 - * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
165 + * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
166 */
167
168 #include <sys/zfs_context.h>
169 @@ -35,14 +35,10 @@
170 #include <sys/zio.h>
171 #include <sys/sunldi.h>
172 #include <linux/mod_compat.h>
173 -#include <linux/msdos_fs.h>
174
175 char *zfs_vdev_scheduler = VDEV_SCHEDULER;
176 static void *zfs_vdev_holder = VDEV_HOLDER;
177
178 -/* size of the "reserved" partition, in blocks */
179 -#define EFI_MIN_RESV_SIZE (16 * 1024)
180 -
181 /*
182 * Virtual device vector for disks.
183 */
184 @@ -86,39 +82,17 @@ vdev_bdev_mode(int smode)
185 }
186 #endif /* HAVE_OPEN_BDEV_EXCLUSIVE */
187
188 -/* The capacity (in bytes) of a bdev that is available to be used by a vdev */
189 static uint64_t
190 -bdev_capacity(struct block_device *bdev, boolean_t wholedisk)
191 +bdev_capacity(struct block_device *bdev)
192 {
193 struct hd_struct *part = bdev->bd_part;
194 - uint64_t sectors = get_capacity(bdev->bd_disk);
195 - /* If there are no paritions, return the entire device capacity */
196 - if (part == NULL)
197 - return (sectors << SECTOR_BITS);
198
199 - /*
200 - * If there are partitions, decide if we are using a `wholedisk`
201 - * layout (composed of part1 and part9) or just a single partition.
202 - */
203 - if (wholedisk) {
204 - /* Verify the expected device layout */
205 - ASSERT3P(bdev, !=, bdev->bd_contains);
206 - /*
207 - * Sectors used by the EFI partition (part9) as well as
208 - * partion alignment.
209 - */
210 - uint64_t used = EFI_MIN_RESV_SIZE + NEW_START_BLOCK +
211 - PARTITION_END_ALIGNMENT;
212 + /* The partition capacity referenced by the block device */
213 + if (part)
214 + return (part->nr_sects << 9);
215
216 - /* Space available to the vdev, i.e. the size of part1 */
217 - if (sectors <= used)
218 - return (0);
219 - uint64_t available = sectors - used;
220 - return (available << SECTOR_BITS);
221 - } else {
222 - /* The partition capacity referenced by the block device */
223 - return (part->nr_sects << SECTOR_BITS);
224 - }
225 + /* Otherwise assume the full device capacity */
226 + return (get_capacity(bdev->bd_disk) << 9);
227 }
228
229 static void
230 @@ -352,7 +326,9 @@ skip_open:
231 v->vdev_nonrot = blk_queue_nonrot(bdev_get_queue(vd->vd_bdev));
232
233 /* Physical volume size in bytes */
234 - *psize = bdev_capacity(vd->vd_bdev, v->vdev_wholedisk);
235 + *psize = bdev_capacity(vd->vd_bdev);
236 +
237 + /* TODO: report possible expansion size */
238 *max_psize = *psize;
239
240 /* Based on the minimum sector size set the block size */
241 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh
242 index 66b6969db..d578ae602 100755
243 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh
244 +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh
245 @@ -26,7 +26,7 @@
246 #
247
248 #
249 -# Copyright (c) 2012, 2018 by Delphix. All rights reserved.
250 +# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
251 # Copyright (c) 2017 Lawrence Livermore National Security, LLC.
252 #
253
254 @@ -43,9 +43,8 @@
255 # 1) Create 3 files
256 # 2) Create a pool backed by the files
257 # 3) Expand the files' size with truncate
258 -# 4) Use zpool reopen to check the expandsize
259 -# 5) Use zpool online -e to online the vdevs
260 -# 6) Check that the pool size was expanded
261 +# 4) Use zpool online -e to online the vdevs
262 +# 5) Check that the pool size was expanded
263 #
264
265 verify_runnable "global"
266 @@ -65,8 +64,8 @@ log_onexit cleanup
267
268 log_assert "zpool can expand after zpool online -e zvol vdevs on LUN expansion"
269
270 +
271 for type in " " mirror raidz raidz2; do
272 - # Initialize the file devices and the pool
273 for i in 1 2 3; do
274 log_must truncate -s $org_size ${TEMPFILE}.$i
275 done
276 @@ -81,35 +80,13 @@ for type in " " mirror raidz raidz2; do
277 "$autoexp"
278 fi
279 typeset prev_size=$(get_pool_prop size $TESTPOOL1)
280 - typeset zfs_prev_size=$(get_prop avail $TESTPOOL1)
281 + typeset zfs_prev_size=$(zfs get -p avail $TESTPOOL1 | tail -1 | \
282 + awk '{print $3}')
283
284 - # Increase the size of the file devices
285 for i in 1 2 3; do
286 log_must truncate -s $exp_size ${TEMPFILE}.$i
287 done
288
289 - # Reopen the pool and check that the `expandsize` property is set
290 - log_must zpool reopen $TESTPOOL1
291 - typeset zpool_expandsize=$(get_pool_prop expandsize $TESTPOOL1)
292 -
293 - if [[ $type == "mirror" ]]; then
294 - typeset expected_zpool_expandsize=$(($exp_size-$org_size))
295 - else
296 - typeset expected_zpool_expandsize=$((3*($exp_size-$org_size)))
297 - fi
298 -
299 - if [[ "$zpool_expandsize" = "-" ]]; then
300 - log_fail "pool $TESTPOOL1 did not detect any " \
301 - "expandsize after reopen"
302 - fi
303 -
304 - if [[ $zpool_expandsize -ne $expected_zpool_expandsize ]]; then
305 - log_fail "pool $TESTPOOL1 did not detect correct " \
306 - "expandsize after reopen: found $zpool_expandsize," \
307 - "expected $expected_zpool_expandsize"
308 - fi
309 -
310 - # Online the devices to add the new space to the pool
311 for i in 1 2 3; do
312 log_must zpool online -e $TESTPOOL1 ${TEMPFILE}.$i
313 done
314 @@ -119,7 +96,8 @@ for type in " " mirror raidz raidz2; do
315 sync
316
317 typeset expand_size=$(get_pool_prop size $TESTPOOL1)
318 - typeset zfs_expand_size=$(get_prop avail $TESTPOOL1)
319 + typeset zfs_expand_size=$(zfs get -p avail $TESTPOOL1 | tail -1 | \
320 + awk '{print $3}')
321 log_note "$TESTPOOL1 $type has previous size: $prev_size and " \
322 "expanded size: $expand_size"
323
324 @@ -134,8 +112,8 @@ for type in " " mirror raidz raidz2; do
325 grep "(+${expansion_size}" | wc -l)
326
327 if [[ $size_addition -ne $i ]]; then
328 - log_fail "pool $TESTPOOL1 did not expand " \
329 - "after LUN expansion and zpool online -e"
330 + log_fail "pool $TESTPOOL1 is not autoexpand " \
331 + "after LUN expansion"
332 fi
333 elif [[ $type == "mirror" ]]; then
334 typeset expansion_size=$(($exp_size-$org_size))
335 @@ -145,8 +123,8 @@ for type in " " mirror raidz raidz2; do
336 grep "(+${expansion_size})" >/dev/null 2>&1
337
338 if [[ $? -ne 0 ]]; then
339 - log_fail "pool $TESTPOOL1 did not expand " \
340 - "after LUN expansion and zpool online -e"
341 + log_fail "pool $TESTPOOL1 is not autoexpand " \
342 + "after LUN expansion"
343 fi
344 else
345 typeset expansion_size=$((3*($exp_size-$org_size)))
346 @@ -156,13 +134,13 @@ for type in " " mirror raidz raidz2; do
347 grep "(+${expansion_size})" >/dev/null 2>&1
348
349 if [[ $? -ne 0 ]] ; then
350 - log_fail "pool $TESTPOOL1 did not expand " \
351 - "after LUN expansion and zpool online -e"
352 + log_fail "pool $TESTPOOL1 is not autoexpand " \
353 + "after LUN expansion"
354 fi
355 fi
356 else
357 - log_fail "pool $TESTPOOL1 did not expand after LUN expansion " \
358 - "and zpool online -e"
359 + log_fail "pool $TESTPOOL1 is not autoexpanded after LUN " \
360 + "expansion"
361 fi
362 log_must zpool destroy $TESTPOOL1
363 done