add zfs 0.7 snapshot
[portage-squeep] / sys-fs / zfs / files / 0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch
1 From a0767672aac01f41516550e3808ff72da893102f Mon Sep 17 00:00:00 2001
2 From: Georgy Yakovlev <gyakovlev@gentoo.org>
3 Date: Tue, 26 Nov 2019 12:07:36 -0800
4 Subject: [PATCH] backport udev timeout patch
5
6 https://github.com/zfsonlinux/zfs/commit/803884217f9b9b5fb235d7c5e78a809d271f6387
7 ---
8 lib/libzfs/libzfs_import.c | 11 ++++++++++-
9 man/man8/zpool.8 | 6 ++++++
10 2 files changed, 16 insertions(+), 1 deletion(-)
11
12 diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
13 index 9dbf207..cd08806 100644
14 --- a/lib/libzfs/libzfs_import.c
15 +++ b/lib/libzfs/libzfs_import.c
16 @@ -53,6 +53,7 @@
17 #endif
18 #include <stddef.h>
19 #include <stdlib.h>
20 +#include <stdio.h>
21 #include <string.h>
22 #include <sys/stat.h>
23 #include <unistd.h>
24 @@ -1594,17 +1595,25 @@ zpool_open_func(void *arg)
25 if (rn->rn_labelpaths) {
26 char *path = NULL;
27 char *devid = NULL;
28 + char *env = NULL;
29 rdsk_node_t *slice;
30 avl_index_t where;
31 + int timeout;
32 int error;
33
34 if (label_paths(rn->rn_hdl, rn->rn_config, &path, &devid))
35 return;
36
37 + env = getenv("ZPOOL_IMPORT_UDEV_TIMEOUT_MS");
38 + if ((env == NULL) || sscanf(env, "%d", &timeout) != 1 ||
39 + timeout < 0) {
40 + timeout = DISK_LABEL_WAIT;
41 + }
42 +
43 /*
44 * Allow devlinks to stabilize so all paths are available.
45 */
46 - zpool_label_disk_wait(rn->rn_name, DISK_LABEL_WAIT);
47 + zpool_label_disk_wait(rn->rn_name, timeout);
48
49 if (path != NULL) {
50 slice = zfs_alloc(hdl, sizeof (rdsk_node_t));
51 diff --git a/man/man8/zpool.8 b/man/man8/zpool.8
52 index 46e531e..10a19b5 100644
53 --- a/man/man8/zpool.8
54 +++ b/man/man8/zpool.8
55 @@ -2291,6 +2291,12 @@ Similar to the
56 option in
57 .Nm zpool import .
58 .El
59 +.Bl -tag -width "ZPOOL_IMPORT_UDEV_TIMEOUT_MS"
60 +.It Ev ZPOOL_IMPORT_UDEV_TIMEOUT_MS
61 +The maximum time in milliseconds that
62 +.Nm zpool import
63 +will wait for an expected device to be available.
64 +.El
65 .Bl -tag -width "ZPOOL_VDEV_NAME_GUID"
66 .It Ev ZPOOL_VDEV_NAME_GUID
67 Cause
68 --
69 2.24.0
70