2013-11-21 15:07:14 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
---
|
2013-12-20 13:23:11 +01:00
|
|
|
journald-kmsg.c | 18 +++++++++++++++---
|
|
|
|
1 file changed, 15 insertions(+), 3 deletions(-)
|
2013-11-21 15:07:14 +01:00
|
|
|
|
|
|
|
Index: systemd-208/src/journal/journald-kmsg.c
|
|
|
|
===================================================================
|
|
|
|
--- systemd-208/src/journal/journald-kmsg.c
|
2013-12-20 13:23:11 +01:00
|
|
|
+++ 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) {
|
2013-11-21 15:07:14 +01:00
|
|
|
|
|
|
|
int server_open_dev_kmsg(Server *s) {
|
|
|
|
struct epoll_event ev;
|
2013-12-20 13:23:11 +01:00
|
|
|
+ int r;
|
2013-11-21 15:07:14 +01:00
|
|
|
|
|
|
|
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");
|
2013-12-20 13:23:11 +01:00
|
|
|
+ log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
|
|
|
|
+ "Failed to open /dev/kmsg, ignoring: %m");
|
2013-11-21 15:07:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-20 13:23:11 +01:00
|
|
|
+ r = 0;
|
2013-11-21 15:07:14 +01:00
|
|
|
zero(ev);
|
|
|
|
ev.events = EPOLLIN;
|
|
|
|
ev.data.fd = s->dev_kmsg_fd;
|
2013-12-20 13:23:11 +01:00
|
|
|
@@ -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;
|
|
|
|
}
|
2013-11-21 15:07:14 +01:00
|
|
|
|
2013-12-20 13:23:11 +01:00
|
|
|
s->dev_kmsg_readable = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
+
|
|
|
|
+fail:
|
|
|
|
+ if (s->dev_kmsg_fd >= 0) {
|
2013-11-21 15:07:14 +01:00
|
|
|
+ close_nointr_nofail(s->dev_kmsg_fd);
|
|
|
|
+ s->dev_kmsg_fd = -1;
|
2013-12-20 13:23:11 +01:00
|
|
|
+ }
|
2013-11-21 15:07:14 +01:00
|
|
|
+
|
2013-12-20 13:23:11 +01:00
|
|
|
+ return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
int server_open_kernel_seqnum(Server *s) {
|