systemd/1011-check-4-valid-kmsg-device.patch

63 lines
1.9 KiB
Diff
Raw Normal View History

From: Werner Fink <werner@suse.de>
Date: Thu, 21 Nov 2013 11:50:32 +0000
Subject: [PATCH] Avoid busy systemd-journald
Avoid a busy systemd-journald due polling a broken /dec/kmsg in lxc
environments.
---
journald-kmsg.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
Index: systemd-208/src/journal/journald-kmsg.c
===================================================================
--- systemd-208/src/journal/journald-kmsg.c
+++ systemd-208/src/journal/journald-kmsg.c 2013-12-20 11:34:39.762236175 +0000
@@ -377,15 +377,18 @@ int server_flush_dev_kmsg(Server *s) {
int server_open_dev_kmsg(Server *s) {
struct epoll_event ev;
+ int r;
assert(s);
s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (s->dev_kmsg_fd < 0) {
- log_warning("Failed to open /dev/kmsg, ignoring: %m");
+ log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
+ "Failed to open /dev/kmsg, ignoring: %m");
return 0;
}
+ r = 0;
zero(ev);
ev.events = EPOLLIN;
ev.data.fd = s->dev_kmsg_fd;
@@ -394,15 +397,24 @@ int server_open_dev_kmsg(Server *s) {
/* This will fail with EPERM on older kernels where
* /dev/kmsg is not readable. */
if (errno == EPERM)
- return 0;
+ goto fail;
log_error("Failed to add /dev/kmsg fd to epoll object: %m");
- return -errno;
+ r = -errno;
+ goto fail;
}
s->dev_kmsg_readable = true;
return 0;
+
+fail:
+ if (s->dev_kmsg_fd >= 0) {
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+ }
+
+ return r;
}
int server_open_kernel_seqnum(Server *s) {