summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2022-02-04 22:34:19 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2022-02-18 18:29:52 +0000
commitc2cd3a449cfa117e3a164f66931fa6c26c762945 (patch)
tree371fdf4e656048a3f8762b119915cbca115461de
parent957246c9e6c47389c40079995d73eebcc659fb29 (diff)
downloadillumos-joyent-c2cd3a449cfa117e3a164f66931fa6c26c762945.tar.gz
14022 zpool online -e breaks access to pool
Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index b06053737c..98d16cd424 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -27,6 +27,7 @@
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
* Copyright (c) 2017 Datto Inc.
* Copyright (c) 2017, Intel Corporation.
+ * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
*/
#include <ctype.h>
@@ -39,6 +40,7 @@
#include <strings.h>
#include <unistd.h>
#include <libgen.h>
+#include <sys/dkio.h>
#include <sys/efi_partition.h>
#include <sys/vtoc.h>
#include <sys/zfs_ioctl.h>
@@ -2797,6 +2799,7 @@ static int
zpool_relabel_disk(libzfs_handle_t *hdl, const char *name, const char *msg)
{
char path[MAXPATHLEN];
+ enum dkio_state st;
int fd, error;
int (*_efi_use_whole_disk)(int);
@@ -2818,12 +2821,25 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *name, const char *msg)
* ignore that error and continue on.
*/
error = _efi_use_whole_disk(fd);
- (void) close(fd);
if (error && error != VT_ENOSPC) {
+ (void) close(fd);
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot "
"relabel '%s': unable to read disk capacity"), name);
return (zfs_error(hdl, EZFS_NOCAP, msg));
}
+
+ /*
+ * Writing a new EFI partition table to the disk will have marked
+ * the geometry as needing re-validation. Before returning, force
+ * it to be checked by querying the device state, otherwise the
+ * subsequent vdev_reopen() will very likely fail to read the device
+ * size, faulting the pool.
+ */
+ st = DKIO_NONE;
+ (void) ioctl(fd, DKIOCSTATE, (caddr_t)&st);
+
+ (void) close(fd);
+
return (0);
}