]> sourceware.org Git - lvm2.git/commitdiff
generators: avoid contacting syslog with generators
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 7 Jan 2019 14:48:39 +0000 (15:48 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 8 Jan 2019 12:13:54 +0000 (13:13 +0100)
The systemd generators are executed very early during the switch
from initramfs to system partition and the syslog is not yet fully
operational - it may cause blocking, if some debug logging is enabled
at the same time in /etc/lvm/lvm.conf log{} section.

To avoid timeouting and killing this generator - rather enhance lvm
code to suppress any syslog communication when LVM_SUPPRESS_SYSLOG
envvar is set.

Use of this envvar is needed since the parsing of i.e. cmdline options
that could eventually override lvm.conf setting happens in this case
way too late and number of lines could have been already streamed to
syslog.

WHATS_NEW
lib/log/log.c
man/lvm.8_main
scripts/generator-internals.c

index 6fdde83ab9a056919bfc1b9041f4da550ae5c2a2..822d045d0d3bb5407b5049dd5ced8877fd32d8a4 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.03.02 - 
 ===================================
+  Introduce LVM_SUPPRESS_SYSLOG to suppress syslog usage by generator.
   Fix generator quering lvmconfig unpresent config option.
   Fix memleak on bcache error path code.
   Fix missing unlock on lvm2 dmeventd plugin error path initialization.
index fd056b14e43caa7b06d8a543db10d61062231713..f6aaa04155bbaffc3c47823a3fa2fb4644e97250 100644 (file)
@@ -324,6 +324,9 @@ void init_log_while_suspended(int log_while_suspended)
 
 void init_syslog(int facility)
 {
+       if (getenv("LVM_SUPPRESS_SYSLOG"))
+               return;
+
        openlog("lvm", LOG_PID, facility);
        _syslog = 1;
 }
index b9abf58f4cc16ef45a850067c585578ad1c1759d..3e67b1bdf60d96d209d7160165adebc8241c22bc 100644 (file)
@@ -435,6 +435,9 @@ Defaults to "\fI#DEFAULT_SYS_DIR#\fP".
 .B LVM_SUPPRESS_FD_WARNINGS
 Suppress warnings about unexpected file descriptors passed into LVM.
 .TP
+.B LVM_SUPPRESS_SYSLOG
+Suppress contacting syslog.
+.TP
 .B LVM_VG_NAME
 The Volume Group name that is assumed for
 any reference to a Logical Volume that doesn't specify a path.
index 839206563518600e51c938b9783f62a3fdde7d42..733e8189c0d711d25b455c15a18dba0ee052b1d6 100644 (file)
@@ -72,6 +72,9 @@ static bool _open_child(struct child_process *child, const char *cmd, const char
                        (void) close(pipe_fd[1]);
                }
 
+               /* Suppressing any use of syslog */
+               (void) setenv("LVM_SUPPRESS_SYSLOG", "1", 1);
+
                if (execv(cmd, (char *const *) argv) < 0)
                        _error("execv failed: %s\n", strerror(errno));
                // Shouldn't get here unless exec failed.
This page took 0.0569809999999999 seconds and 5 git commands to generate.