xref: /freebsd-src/sys/contrib/openzfs/lib/libzfs/os/linux/libzfs_pool_os.c (revision aca928a50a42f00f344df934005b09dbcb4e2f77)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9271171e0SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy 
22eda14cbcSMatt Macy /*
23eda14cbcSMatt Macy  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
24eda14cbcSMatt Macy  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
25eda14cbcSMatt Macy  * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
26eda14cbcSMatt Macy  * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
27eda14cbcSMatt Macy  * Copyright (c) 2018 Datto Inc.
28eda14cbcSMatt Macy  * Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
29eda14cbcSMatt Macy  * Copyright (c) 2017, Intel Corporation.
30eda14cbcSMatt Macy  * Copyright (c) 2018, loli10K <ezomori.nozomu@gmail.com>
31eda14cbcSMatt Macy  */
32eda14cbcSMatt Macy 
33eda14cbcSMatt Macy #include <errno.h>
34eda14cbcSMatt Macy #include <libintl.h>
35eda14cbcSMatt Macy #include <stdio.h>
36eda14cbcSMatt Macy #include <stdlib.h>
37da5137abSMartin Matuska #include <string.h>
38eda14cbcSMatt Macy #include <unistd.h>
39eda14cbcSMatt Macy #include <libgen.h>
40eda14cbcSMatt Macy #include <zone.h>
41eda14cbcSMatt Macy #include <sys/stat.h>
42eda14cbcSMatt Macy #include <sys/efi_partition.h>
43eda14cbcSMatt Macy #include <sys/systeminfo.h>
44eda14cbcSMatt Macy #include <sys/zfs_ioctl.h>
45eda14cbcSMatt Macy #include <sys/vdev_disk.h>
46eda14cbcSMatt Macy #include <dlfcn.h>
47eda14cbcSMatt Macy #include <libzutil.h>
48eda14cbcSMatt Macy 
49eda14cbcSMatt Macy #include "zfs_namecheck.h"
50eda14cbcSMatt Macy #include "zfs_prop.h"
5116038816SMartin Matuska #include "../../libzfs_impl.h"
52eda14cbcSMatt Macy #include "zfs_comutil.h"
53eda14cbcSMatt Macy #include "zfeature_common.h"
54eda14cbcSMatt Macy 
55eda14cbcSMatt Macy /*
56eda14cbcSMatt Macy  * If the device has being dynamically expanded then we need to relabel
57eda14cbcSMatt Macy  * the disk to use the new unallocated space.
58eda14cbcSMatt Macy  */
59eda14cbcSMatt Macy int
zpool_relabel_disk(libzfs_handle_t * hdl,const char * path,const char * msg)60eda14cbcSMatt Macy zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg)
61eda14cbcSMatt Macy {
62eda14cbcSMatt Macy 	int fd, error;
63eda14cbcSMatt Macy 
6416038816SMartin Matuska 	if ((fd = open(path, O_RDWR|O_DIRECT|O_CLOEXEC)) < 0) {
65eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
66eda14cbcSMatt Macy 		    "relabel '%s': unable to open device: %d"), path, errno);
67eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_OPENFAILED, msg));
68eda14cbcSMatt Macy 	}
69eda14cbcSMatt Macy 
70eda14cbcSMatt Macy 	/*
71eda14cbcSMatt Macy 	 * It's possible that we might encounter an error if the device
72eda14cbcSMatt Macy 	 * does not have any unallocated space left. If so, we simply
73eda14cbcSMatt Macy 	 * ignore that error and continue on.
74eda14cbcSMatt Macy 	 */
75eda14cbcSMatt Macy 	error = efi_use_whole_disk(fd);
76eda14cbcSMatt Macy 
77eda14cbcSMatt Macy 	/* Flush the buffers to disk and invalidate the page cache. */
78eda14cbcSMatt Macy 	(void) fsync(fd);
79eda14cbcSMatt Macy 	(void) ioctl(fd, BLKFLSBUF);
80eda14cbcSMatt Macy 
81eda14cbcSMatt Macy 	(void) close(fd);
82eda14cbcSMatt Macy 	if (error && error != VT_ENOSPC) {
83eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
84eda14cbcSMatt Macy 		    "relabel '%s': unable to read disk capacity"), path);
85eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_NOCAP, msg));
86eda14cbcSMatt Macy 	}
87eda14cbcSMatt Macy 	return (0);
88eda14cbcSMatt Macy }
89eda14cbcSMatt Macy 
90eda14cbcSMatt Macy /*
91eda14cbcSMatt Macy  * Read the EFI label from the config, if a label does not exist then
92eda14cbcSMatt Macy  * pass back the error to the caller. If the caller has passed a non-NULL
93eda14cbcSMatt Macy  * diskaddr argument then we set it to the starting address of the EFI
94eda14cbcSMatt Macy  * partition.
95eda14cbcSMatt Macy  */
96eda14cbcSMatt Macy static int
read_efi_label(nvlist_t * config,diskaddr_t * sb)97eda14cbcSMatt Macy read_efi_label(nvlist_t *config, diskaddr_t *sb)
98eda14cbcSMatt Macy {
992a58b312SMartin Matuska 	const char *path;
100eda14cbcSMatt Macy 	int fd;
101eda14cbcSMatt Macy 	char diskname[MAXPATHLEN];
102eda14cbcSMatt Macy 	int err = -1;
103eda14cbcSMatt Macy 
104eda14cbcSMatt Macy 	if (nvlist_lookup_string(config, ZPOOL_CONFIG_PATH, &path) != 0)
105eda14cbcSMatt Macy 		return (err);
106eda14cbcSMatt Macy 
107eda14cbcSMatt Macy 	(void) snprintf(diskname, sizeof (diskname), "%s%s", DISK_ROOT,
108eda14cbcSMatt Macy 	    strrchr(path, '/'));
10916038816SMartin Matuska 	if ((fd = open(diskname, O_RDONLY|O_DIRECT|O_CLOEXEC)) >= 0) {
110eda14cbcSMatt Macy 		struct dk_gpt *vtoc;
111eda14cbcSMatt Macy 
112eda14cbcSMatt Macy 		if ((err = efi_alloc_and_read(fd, &vtoc)) >= 0) {
113eda14cbcSMatt Macy 			if (sb != NULL)
114eda14cbcSMatt Macy 				*sb = vtoc->efi_parts[0].p_start;
115eda14cbcSMatt Macy 			efi_free(vtoc);
116eda14cbcSMatt Macy 		}
117eda14cbcSMatt Macy 		(void) close(fd);
118eda14cbcSMatt Macy 	}
119eda14cbcSMatt Macy 	return (err);
120eda14cbcSMatt Macy }
121eda14cbcSMatt Macy 
122eda14cbcSMatt Macy /*
123eda14cbcSMatt Macy  * determine where a partition starts on a disk in the current
124eda14cbcSMatt Macy  * configuration
125eda14cbcSMatt Macy  */
126eda14cbcSMatt Macy static diskaddr_t
find_start_block(nvlist_t * config)127eda14cbcSMatt Macy find_start_block(nvlist_t *config)
128eda14cbcSMatt Macy {
129eda14cbcSMatt Macy 	nvlist_t **child;
130eda14cbcSMatt Macy 	uint_t c, children;
131eda14cbcSMatt Macy 	diskaddr_t sb = MAXOFFSET_T;
132eda14cbcSMatt Macy 	uint64_t wholedisk;
133eda14cbcSMatt Macy 
134eda14cbcSMatt Macy 	if (nvlist_lookup_nvlist_array(config,
135eda14cbcSMatt Macy 	    ZPOOL_CONFIG_CHILDREN, &child, &children) != 0) {
136eda14cbcSMatt Macy 		if (nvlist_lookup_uint64(config,
137eda14cbcSMatt Macy 		    ZPOOL_CONFIG_WHOLE_DISK,
138eda14cbcSMatt Macy 		    &wholedisk) != 0 || !wholedisk) {
139eda14cbcSMatt Macy 			return (MAXOFFSET_T);
140eda14cbcSMatt Macy 		}
141eda14cbcSMatt Macy 		if (read_efi_label(config, &sb) < 0)
142eda14cbcSMatt Macy 			sb = MAXOFFSET_T;
143eda14cbcSMatt Macy 		return (sb);
144eda14cbcSMatt Macy 	}
145eda14cbcSMatt Macy 
146eda14cbcSMatt Macy 	for (c = 0; c < children; c++) {
147eda14cbcSMatt Macy 		sb = find_start_block(child[c]);
148eda14cbcSMatt Macy 		if (sb != MAXOFFSET_T) {
149eda14cbcSMatt Macy 			return (sb);
150eda14cbcSMatt Macy 		}
151eda14cbcSMatt Macy 	}
152eda14cbcSMatt Macy 	return (MAXOFFSET_T);
153eda14cbcSMatt Macy }
154eda14cbcSMatt Macy 
155eda14cbcSMatt Macy static int
zpool_label_disk_check(char * path)156eda14cbcSMatt Macy zpool_label_disk_check(char *path)
157eda14cbcSMatt Macy {
158eda14cbcSMatt Macy 	struct dk_gpt *vtoc;
159eda14cbcSMatt Macy 	int fd, err;
160eda14cbcSMatt Macy 
16116038816SMartin Matuska 	if ((fd = open(path, O_RDONLY|O_DIRECT|O_CLOEXEC)) < 0)
162eda14cbcSMatt Macy 		return (errno);
163eda14cbcSMatt Macy 
164eda14cbcSMatt Macy 	if ((err = efi_alloc_and_read(fd, &vtoc)) != 0) {
165eda14cbcSMatt Macy 		(void) close(fd);
166eda14cbcSMatt Macy 		return (err);
167eda14cbcSMatt Macy 	}
168eda14cbcSMatt Macy 
169eda14cbcSMatt Macy 	if (vtoc->efi_flags & EFI_GPT_PRIMARY_CORRUPT) {
170eda14cbcSMatt Macy 		efi_free(vtoc);
171eda14cbcSMatt Macy 		(void) close(fd);
172eda14cbcSMatt Macy 		return (EIDRM);
173eda14cbcSMatt Macy 	}
174eda14cbcSMatt Macy 
175eda14cbcSMatt Macy 	efi_free(vtoc);
176eda14cbcSMatt Macy 	(void) close(fd);
177eda14cbcSMatt Macy 	return (0);
178eda14cbcSMatt Macy }
179eda14cbcSMatt Macy 
180eda14cbcSMatt Macy /*
181eda14cbcSMatt Macy  * Generate a unique partition name for the ZFS member.  Partitions must
182eda14cbcSMatt Macy  * have unique names to ensure udev will be able to create symlinks under
183eda14cbcSMatt Macy  * /dev/disk/by-partlabel/ for all pool members.  The partition names are
184eda14cbcSMatt Macy  * of the form <pool>-<unique-id>.
185eda14cbcSMatt Macy  */
186eda14cbcSMatt Macy static void
zpool_label_name(char * label_name,int label_size)187eda14cbcSMatt Macy zpool_label_name(char *label_name, int label_size)
188eda14cbcSMatt Macy {
189eda14cbcSMatt Macy 	uint64_t id = 0;
190eda14cbcSMatt Macy 	int fd;
191eda14cbcSMatt Macy 
19216038816SMartin Matuska 	fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC);
193eda14cbcSMatt Macy 	if (fd >= 0) {
194eda14cbcSMatt Macy 		if (read(fd, &id, sizeof (id)) != sizeof (id))
195eda14cbcSMatt Macy 			id = 0;
196eda14cbcSMatt Macy 
197eda14cbcSMatt Macy 		close(fd);
198eda14cbcSMatt Macy 	}
199eda14cbcSMatt Macy 
200eda14cbcSMatt Macy 	if (id == 0)
201eda14cbcSMatt Macy 		id = (((uint64_t)rand()) << 32) | (uint64_t)rand();
202eda14cbcSMatt Macy 
203eda14cbcSMatt Macy 	snprintf(label_name, label_size, "zfs-%016llx", (u_longlong_t)id);
204eda14cbcSMatt Macy }
205eda14cbcSMatt Macy 
206eda14cbcSMatt Macy /*
207eda14cbcSMatt Macy  * Label an individual disk.  The name provided is the short name,
208eda14cbcSMatt Macy  * stripped of any leading /dev path.
209eda14cbcSMatt Macy  */
210eda14cbcSMatt Macy int
zpool_label_disk(libzfs_handle_t * hdl,zpool_handle_t * zhp,const char * name)211eda14cbcSMatt Macy zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
212eda14cbcSMatt Macy {
213eda14cbcSMatt Macy 	char path[MAXPATHLEN];
214eda14cbcSMatt Macy 	struct dk_gpt *vtoc;
215eda14cbcSMatt Macy 	int rval, fd;
216eda14cbcSMatt Macy 	size_t resv = EFI_MIN_RESV_SIZE;
217eda14cbcSMatt Macy 	uint64_t slice_size;
218eda14cbcSMatt Macy 	diskaddr_t start_block;
2191f1e2261SMartin Matuska 	char errbuf[ERRBUFLEN];
220eda14cbcSMatt Macy 
221eda14cbcSMatt Macy 	/* prepare an error message just in case */
222eda14cbcSMatt Macy 	(void) snprintf(errbuf, sizeof (errbuf),
223eda14cbcSMatt Macy 	    dgettext(TEXT_DOMAIN, "cannot label '%s'"), name);
224eda14cbcSMatt Macy 
225eda14cbcSMatt Macy 	if (zhp) {
226da5137abSMartin Matuska 		nvlist_t *nvroot = fnvlist_lookup_nvlist(zhp->zpool_config,
227da5137abSMartin Matuska 		    ZPOOL_CONFIG_VDEV_TREE);
228eda14cbcSMatt Macy 
229eda14cbcSMatt Macy 		if (zhp->zpool_start_block == 0)
230eda14cbcSMatt Macy 			start_block = find_start_block(nvroot);
231eda14cbcSMatt Macy 		else
232eda14cbcSMatt Macy 			start_block = zhp->zpool_start_block;
233eda14cbcSMatt Macy 		zhp->zpool_start_block = start_block;
234eda14cbcSMatt Macy 	} else {
235eda14cbcSMatt Macy 		/* new pool */
236eda14cbcSMatt Macy 		start_block = NEW_START_BLOCK;
237eda14cbcSMatt Macy 	}
238eda14cbcSMatt Macy 
239eda14cbcSMatt Macy 	(void) snprintf(path, sizeof (path), "%s/%s", DISK_ROOT, name);
240eda14cbcSMatt Macy 
24116038816SMartin Matuska 	if ((fd = open(path, O_RDWR|O_DIRECT|O_EXCL|O_CLOEXEC)) < 0) {
242eda14cbcSMatt Macy 		/*
243eda14cbcSMatt Macy 		 * This shouldn't happen.  We've long since verified that this
244eda14cbcSMatt Macy 		 * is a valid device.
245eda14cbcSMatt Macy 		 */
246eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
247eda14cbcSMatt Macy 		    "label '%s': unable to open device: %d"), path, errno);
248eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_OPENFAILED, errbuf));
249eda14cbcSMatt Macy 	}
250eda14cbcSMatt Macy 
251eda14cbcSMatt Macy 	if (efi_alloc_and_init(fd, EFI_NUMPAR, &vtoc) != 0) {
252eda14cbcSMatt Macy 		/*
253eda14cbcSMatt Macy 		 * The only way this can fail is if we run out of memory, or we
254eda14cbcSMatt Macy 		 * were unable to read the disk's capacity
255eda14cbcSMatt Macy 		 */
256eda14cbcSMatt Macy 		if (errno == ENOMEM)
257eda14cbcSMatt Macy 			(void) no_memory(hdl);
258eda14cbcSMatt Macy 
259eda14cbcSMatt Macy 		(void) close(fd);
260eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
261eda14cbcSMatt Macy 		    "label '%s': unable to read disk capacity"), path);
262eda14cbcSMatt Macy 
263eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_NOCAP, errbuf));
264eda14cbcSMatt Macy 	}
265eda14cbcSMatt Macy 
266eda14cbcSMatt Macy 	slice_size = vtoc->efi_last_u_lba + 1;
267eda14cbcSMatt Macy 	slice_size -= EFI_MIN_RESV_SIZE;
268eda14cbcSMatt Macy 	if (start_block == MAXOFFSET_T)
269eda14cbcSMatt Macy 		start_block = NEW_START_BLOCK;
270eda14cbcSMatt Macy 	slice_size -= start_block;
271*aca928a5SMartin Matuska 	slice_size = P2ALIGN_TYPED(slice_size, PARTITION_END_ALIGNMENT,
272*aca928a5SMartin Matuska 	    uint64_t);
273eda14cbcSMatt Macy 
274eda14cbcSMatt Macy 	vtoc->efi_parts[0].p_start = start_block;
275eda14cbcSMatt Macy 	vtoc->efi_parts[0].p_size = slice_size;
276eda14cbcSMatt Macy 
2774fefe1b7SMartin Matuska 	if (vtoc->efi_parts[0].p_size * vtoc->efi_lbasize < SPA_MINDEVSIZE) {
2784fefe1b7SMartin Matuska 		(void) close(fd);
2794fefe1b7SMartin Matuska 		efi_free(vtoc);
2804fefe1b7SMartin Matuska 
2814fefe1b7SMartin Matuska 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
2824fefe1b7SMartin Matuska 		    "label '%s': partition would be less than the minimum "
2834fefe1b7SMartin Matuska 		    "device size (64M)"), path);
2844fefe1b7SMartin Matuska 		return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
2854fefe1b7SMartin Matuska 	}
2864fefe1b7SMartin Matuska 
287eda14cbcSMatt Macy 	/*
288eda14cbcSMatt Macy 	 * Why we use V_USR: V_BACKUP confuses users, and is considered
289eda14cbcSMatt Macy 	 * disposable by some EFI utilities (since EFI doesn't have a backup
290eda14cbcSMatt Macy 	 * slice).  V_UNASSIGNED is supposed to be used only for zero size
291da5137abSMartin Matuska 	 * partitions, and efi_write() will fail if we use it.
292da5137abSMartin Matuska 	 * Other available types were all pretty specific.
293da5137abSMartin Matuska 	 * V_USR is as close to reality as we
294eda14cbcSMatt Macy 	 * can get, in the absence of V_OTHER.
295eda14cbcSMatt Macy 	 */
296eda14cbcSMatt Macy 	vtoc->efi_parts[0].p_tag = V_USR;
297eda14cbcSMatt Macy 	zpool_label_name(vtoc->efi_parts[0].p_name, EFI_PART_NAME_LEN);
298eda14cbcSMatt Macy 
299eda14cbcSMatt Macy 	vtoc->efi_parts[8].p_start = slice_size + start_block;
300eda14cbcSMatt Macy 	vtoc->efi_parts[8].p_size = resv;
301eda14cbcSMatt Macy 	vtoc->efi_parts[8].p_tag = V_RESERVED;
302eda14cbcSMatt Macy 
303eda14cbcSMatt Macy 	rval = efi_write(fd, vtoc);
304eda14cbcSMatt Macy 
305eda14cbcSMatt Macy 	/* Flush the buffers to disk and invalidate the page cache. */
306eda14cbcSMatt Macy 	(void) fsync(fd);
307eda14cbcSMatt Macy 	(void) ioctl(fd, BLKFLSBUF);
308eda14cbcSMatt Macy 
309eda14cbcSMatt Macy 	if (rval == 0)
310eda14cbcSMatt Macy 		rval = efi_rescan(fd);
311eda14cbcSMatt Macy 
312eda14cbcSMatt Macy 	/*
313eda14cbcSMatt Macy 	 * Some block drivers (like pcata) may not support EFI GPT labels.
314eda14cbcSMatt Macy 	 * Print out a helpful error message directing the user to manually
315eda14cbcSMatt Macy 	 * label the disk and give a specific slice.
316eda14cbcSMatt Macy 	 */
317eda14cbcSMatt Macy 	if (rval != 0) {
318eda14cbcSMatt Macy 		(void) close(fd);
319eda14cbcSMatt Macy 		efi_free(vtoc);
320eda14cbcSMatt Macy 
321eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "try using "
322eda14cbcSMatt Macy 		    "parted(8) and then provide a specific slice: %d"), rval);
323eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
324eda14cbcSMatt Macy 	}
325eda14cbcSMatt Macy 
326eda14cbcSMatt Macy 	(void) close(fd);
327eda14cbcSMatt Macy 	efi_free(vtoc);
328eda14cbcSMatt Macy 
329eda14cbcSMatt Macy 	(void) snprintf(path, sizeof (path), "%s/%s", DISK_ROOT, name);
330eda14cbcSMatt Macy 	(void) zfs_append_partition(path, MAXPATHLEN);
331eda14cbcSMatt Macy 
332eda14cbcSMatt Macy 	/* Wait to udev to signal use the device has settled. */
333eda14cbcSMatt Macy 	rval = zpool_label_disk_wait(path, DISK_LABEL_WAIT);
334eda14cbcSMatt Macy 	if (rval) {
335eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "failed to "
336eda14cbcSMatt Macy 		    "detect device partitions on '%s': %d"), path, rval);
337eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
338eda14cbcSMatt Macy 	}
339eda14cbcSMatt Macy 
340eda14cbcSMatt Macy 	/* We can't be to paranoid.  Read the label back and verify it. */
341eda14cbcSMatt Macy 	(void) snprintf(path, sizeof (path), "%s/%s", DISK_ROOT, name);
342eda14cbcSMatt Macy 	rval = zpool_label_disk_check(path);
343eda14cbcSMatt Macy 	if (rval) {
344eda14cbcSMatt Macy 		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "freshly written "
345eda14cbcSMatt Macy 		    "EFI label on '%s' is damaged.  Ensure\nthis device "
346eda14cbcSMatt Macy 		    "is not in use, and is functioning properly: %d"),
347eda14cbcSMatt Macy 		    path, rval);
348eda14cbcSMatt Macy 		return (zfs_error(hdl, EZFS_LABELFAILED, errbuf));
349eda14cbcSMatt Macy 	}
350eda14cbcSMatt Macy 	return (0);
351eda14cbcSMatt Macy }
352