diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index 28733cc747..e84680a797 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -1651,17 +1651,25 @@ zpool_open_func(void *arg) if (rn->rn_labelpaths) { char *path = NULL; char *devid = NULL; + char *env = NULL; rdsk_node_t *slice; avl_index_t where; + int timeout; int error; if (label_paths(rn->rn_hdl, rn->rn_config, &path, &devid)) return; + env = getenv("ZPOOL_IMPORT_UDEV_TIMEOUT_MS"); + if ((env == NULL) || sscanf(env, "%d", &timeout) != 1 || + timeout < 0) { + timeout = DISK_LABEL_WAIT; + } + /* * Allow devlinks to stabilize so all paths are available. */ - zpool_label_disk_wait(rn->rn_name, DISK_LABEL_WAIT); + zpool_label_disk_wait(rn->rn_name, timeout); if (path != NULL) { slice = zfs_alloc(hdl, sizeof (rdsk_node_t)); diff --git a/man/man8/zpool.8 b/man/man8/zpool.8 index bdad81149b..adbb723aae 100644 --- a/man/man8/zpool.8 +++ b/man/man8/zpool.8 @@ -2740,6 +2740,12 @@ Similar to the option in .Nm zpool import . .El +.Bl -tag -width "ZPOOL_IMPORT_UDEV_TIMEOUT_MS" +.It Ev ZPOOL_IMPORT_UDEV_TIMEOUT_MS +The maximum time in milliseconds that +.Nm zpool import +will wait for an expected device to be available. +.El .Bl -tag -width "ZPOOL_VDEV_NAME_GUID" .It Ev ZPOOL_VDEV_NAME_GUID Cause