SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2013-11-21 14:07:14 +00:00 committed by Git OBS Bridge
parent 49d1097dfe
commit 7e450ee836
3 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,70 @@
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 | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
Index: systemd-208/src/journal/journald-kmsg.c
===================================================================
--- systemd-208/src/journal/journald-kmsg.c
+++ systemd-208/src/journal/journald-kmsg.c 2013-11-21 13:30:22.930735683 +0000
@@ -23,7 +23,9 @@
#include <sys/epoll.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <systemd/sd-messages.h>
#include <libudev.h>
@@ -377,20 +379,43 @@ int server_flush_dev_kmsg(Server *s) {
int server_open_dev_kmsg(Server *s) {
struct epoll_event ev;
+ struct stat st;
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");
+ /* Do not warn as it may not exists in LXC environments */
+ if (errno != ENOENT)
+ log_warning("Failed to open /dev/kmsg, ignoring: %m");
return 0;
}
+ if (fstat(s->dev_kmsg_fd, &st) < 0) {
+ log_error("Failed to stat /dev/kmsg fd, ignoring: %m");
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+ return 0;
+ }
+
+ if (!S_ISCHR(st.st_mode) || major(st.st_rdev) != 1 || minor(st.st_rdev) != 11) {
+ int old_errno = errno;
+ errno = ENODEV;
+ log_warning("Irregular device /dev/kmsg, ignoring: %m");
+ errno = old_errno;
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+ return 0;
+ }
+
zero(ev);
ev.events = EPOLLIN;
ev.data.fd = s->dev_kmsg_fd;
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, s->dev_kmsg_fd, &ev) < 0) {
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+
/* This will fail with EPERM on older kernels where
* /dev/kmsg is not readable. */
if (errno == EPERM)

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Nov 21 12:27:11 UTC 2013 - werner@suse.de
- Add patch
1011-check-4-valid-kmsg-device.patch
to avoid a busy systemd-journald (bnc#851393)
-------------------------------------------------------------------
Wed Nov 6 09:42:05 UTC 2013 - werner@suse.de

View File

@ -258,6 +258,8 @@ Patch1008: 1008-add-msft-compability-rules.patch
Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch
# PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071)
Patch1010: 1010-do-not-install-sulogin-unit-with-poweroff.patch
# PATCH-FIX-OPENSUSE 1011-check-4-valid-kmsg-device.patch -- Avoid busy systemd-journald (bnc#851393)
Patch1011: 1011-check-4-valid-kmsg-device.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -534,6 +536,7 @@ cp %{SOURCE7} m4/
%endif
%patch1009 -p1
%patch1010 -p1
%patch1011 -p1
# ensure generate files are removed
rm -f units/emergency.service