Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/lvm2/files/, sys-fs/lvm2/
Date: Wed, 17 Apr 2019 07:26:57
Message-Id: 1555485938.04b17140f5801dc924927a418f43cfe765afc778.robbat2@gentoo
1 commit: 04b17140f5801dc924927a418f43cfe765afc778
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 17 07:04:10 2019 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 17 07:25:38 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=04b17140
7
8 sys-fs/lvm2: improve dmeventd init
9
10 Upstream dmeventd has an exit-on-idle behavior that leads openrc to
11 decide that it has crashed, when it just exited "normally".
12
13 Provide multiple ways around this:
14 - supervisor support in the init script
15 - patch the daemon to make the idle timeout configurable (submitted upstream)
16
17 Co-authored-by: William Hubbs <williamh <AT> gentoo.org>
18 Fixes: https://bugs.gentoo.org/682556
19 Package-Manager: Portage-2.3.62, Repoman-2.3.12
20 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
21
22 sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2 | 21 +++++++
23 .../lvm2-2.02.184-dmeventd-no-idle-exit.patch | 68 ++++++++++++++++++++++
24 sys-fs/lvm2/lvm2-2.02.184-r2.ebuild | 3 +-
25 3 files changed, 91 insertions(+), 1 deletion(-)
26
27 diff --git a/sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2 b/sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2
28 new file mode 100644
29 index 00000000000..bc08c0a94f4
30 --- /dev/null
31 +++ b/sys-fs/lvm2/files/dmeventd.initd-2.02.184-r2
32 @@ -0,0 +1,21 @@
33 +#!/sbin/openrc-run
34 +# Copyright 1999-2019 Gentoo Authors
35 +# Distributed under the terms of the GNU General Public License v2
36 +
37 +command=/sbin/dmeventd
38 +command_args_foreground='-f'
39 +extra_started_commands=reload
40 +pidfile=/run/dmeventd.pid
41 +# Control idle exit behavior of daemon
42 +export DMEVENTD_IDLE_EXIT_TIMEOUT=${DMEVENTD_IDLE_EXIT_TIMEOUT:=-1}
43 +
44 +depend() {
45 + # As of .67-r1, we call ALL lvm start/stop scripts with --sysinit, that
46 + # means dmeventd is NOT notified, as it cannot be safely running
47 + after lvm device-mapper
48 +}
49 +
50 +reload() {
51 + # TODO: this is not supported under supervisors
52 + ${command} -R
53 +}
54
55 diff --git a/sys-fs/lvm2/files/lvm2-2.02.184-dmeventd-no-idle-exit.patch b/sys-fs/lvm2/files/lvm2-2.02.184-dmeventd-no-idle-exit.patch
56 new file mode 100644
57 index 00000000000..c80bd2ba2be
58 --- /dev/null
59 +++ b/sys-fs/lvm2/files/lvm2-2.02.184-dmeventd-no-idle-exit.patch
60 @@ -0,0 +1,68 @@
61 +From: "Robin H. Johnson" <robbat2@g.o>
62 +Date: Wed, 17 Apr 2019 06:54:27 +0000
63 +Subject: [PATCH] dmeventd configurable idle exit time
64 +
65 +dmeventd nominally exits after 1 hour of idle time. There are use cases for
66 +this, esp. with socket activation, but also cases where users don't expect
67 +dmeventd to exit.
68 +
69 +Provide a tuning knob via environment variable, DMEVENTD_IDLE_EXIT_TIMEOUT,
70 +that can be -1 to not exit, or a configurable time for different idle exit.
71 +
72 +Signed-off-by: Robin H. Johnson <robbat2@g.o>
73 +Fixes: https://bugs.gentoo.org/682556
74 +
75 +diff -Nuar LVM2.2.02.184.orig/daemons/dmeventd/dmeventd.c LVM2.2.02.184/daemons/dmeventd/dmeventd.c
76 +--- LVM2.2.02.184.orig/daemons/dmeventd/dmeventd.c 2019-03-22 03:14:59.000000000 -0700
77 ++++ LVM2.2.02.184/daemons/dmeventd/dmeventd.c 2019-04-17 00:18:23.535029906 -0700
78 +@@ -2158,6 +2158,18 @@
79 + .server_path = DM_EVENT_FIFO_SERVER
80 + };
81 + time_t now, idle_exit_timeout = DMEVENTD_IDLE_EXIT_TIMEOUT;
82 ++
83 ++ /* Provide a basic way to config the idle timeout */
84 ++ char* idle_exit_timeout_env = getenv("DMEVENTD_IDLE_EXIT_TIMEOUT") ? : NULL;
85 ++ if(NULL != idle_exit_timeout_env) {
86 ++ char* endptr;
87 ++ idle_exit_timeout = strtol(idle_exit_timeout_env, &endptr, 10);
88 ++ if (errno == ERANGE || *endptr != '\0') {
89 ++ fprintf(stderr, "DMEVENTD_IDLE_EXIT_TIMEOUT: bad time input\n");
90 ++ exit(EXIT_FAILURE);
91 ++ }
92 ++ }
93 ++
94 + opterr = 0;
95 + optind = 0;
96 +
97 +@@ -2253,7 +2265,7 @@
98 + _process_initial_registrations();
99 +
100 + for (;;) {
101 +- if (_idle_since) {
102 ++ if (_idle_since || _exit_now) {
103 + if (_exit_now) {
104 + if (_exit_now == DM_SCHEDULED_EXIT)
105 + break; /* Only prints shutdown message */
106 +@@ -2262,7 +2274,7 @@
107 + (long) (time(NULL) - _idle_since));
108 + break;
109 + }
110 +- if (idle_exit_timeout) {
111 ++ if (idle_exit_timeout && idle_exit_timeout > 0) {
112 + now = time(NULL);
113 + if (now < _idle_since)
114 + _idle_since = now; /* clock change? */
115 +diff -Nuar LVM2.2.02.184.orig/man/dmeventd.8_main LVM2.2.02.184/man/dmeventd.8_main
116 +--- LVM2.2.02.184.orig/man/dmeventd.8_main 2019-03-22 03:15:00.000000000 -0700
117 ++++ LVM2.2.02.184/man/dmeventd.8_main 2019-04-17 00:17:46.076023638 -0700
118 +@@ -143,6 +143,10 @@
119 + Variable is set by thin plugin to prohibit recursive interation
120 + with dmeventd by any executed lvm2 command from
121 + a thin_command environment.
122 ++.TP
123 ++.B DMEVENTD_IDLE_EXIT_TIMEOUT
124 ++Configure the dmeventd idle exit timeout behavior, value in seconds. Default
125 ++is 3600 (1 hour). -1 means do not exit.
126 + .
127 + .SH SEE ALSO
128 + .
129
130 diff --git a/sys-fs/lvm2/lvm2-2.02.184-r2.ebuild b/sys-fs/lvm2/lvm2-2.02.184-r2.ebuild
131 index 64a1656d31b..8ff1308f584 100644
132 --- a/sys-fs/lvm2/lvm2-2.02.184-r2.ebuild
133 +++ b/sys-fs/lvm2/lvm2-2.02.184-r2.ebuild
134 @@ -65,6 +65,7 @@ PATCHES=(
135 "${FILESDIR}"/${PN}-2.02.171-static-libm.patch #617756
136 "${FILESDIR}"/${PN}-2.02.166-HPPA-no-O_DIRECT.patch #657446
137 #"${FILESDIR}"/${PN}-2.02.145-mkdev.patch #580062 # Merged upstream
138 + "${FILESDIR}"/${PN}-2.02.184-dmeventd-no-idle-exit.patch
139 )
140
141 pkg_setup() {
142 @@ -213,7 +214,7 @@ src_install() {
143 newconfd "${FILESDIR}"/device-mapper.conf-1.02.22-r3 device-mapper
144
145 if use !device-mapper-only ; then
146 - newinitd "${FILESDIR}"/dmeventd.initd-2.02.67-r1 dmeventd
147 + newinitd "${FILESDIR}"/dmeventd.initd-2.02.184-r2 dmeventd
148 newinitd "${FILESDIR}"/lvm.rc-2.02.183 lvm
149 newconfd "${FILESDIR}"/lvm.confd-2.02.28-r2 lvm