diff options
author | Richard Yao <[email protected]> | 2019-10-09 12:16:12 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-10-11 09:52:48 -0700 |
commit | 803884217f9b9b5fb235d7c5e78a809d271f6387 (patch) | |
tree | 6da88c46eef5a65e1fc6bb970d5f4f6679915474 /lib | |
parent | d96635a5c7ba539c2f56c245c662be5b914f93e1 (diff) |
Implement ZPOOL_IMPORT_UDEV_TIMEOUT_MS
Since 0.7.0, zpool import would unconditionally block on udev for 30
seconds. This introduced a regression in initramfs environments that
lack udev (particularly mdev based environments), yet use a zfs userland
tools intended for the system that had been built against udev. Gentoo's
genkernel is the main example, although custom user initramfs
environments would be similarly impacted unless special builds of the
ZFS userland utilities were done for them. Such environments already
have their own mechanisms for blocking until device nodes are ready
(such as genkernel's scandelay parameter), so it is unnecessary for
zpool import to block on a non-existent udev until a timeout is reached
inside of them.
Rather than trying to intelligently determine whether udev is available
on the system to avoid unnecessarily blocking in such environments, it
seems best to just allow the environment to override the timeout. I
propose that we add an environment variable called
ZPOOL_IMPORT_UDEV_TIMEOUT_MS. Setting it to 0 would restore the 0.6.x
behavior that was more desirable in mdev based initramfs environments.
This allows the system user land utilities to be reused when building
mdev-based initramfs archives.
Reviewed-by: Igor Kozhukhov <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Georgy Yakovlev <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #9436
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzutil/os/linux/zutil_import_os.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c index 811eae397..e51004edc 100644 --- a/lib/libzutil/os/linux/zutil_import_os.c +++ b/lib/libzutil/os/linux/zutil_import_os.c @@ -53,6 +53,7 @@ #include <libgen.h> #include <stddef.h> #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> @@ -181,17 +182,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 = zutil_alloc(hdl, sizeof (rdsk_node_t)); |