[systemd/f15] Slowing down in F15. Only a few fixes for bugs reported against F15
Michal Schmidt
michich at fedoraproject.org
Tue Jan 17 12:56:33 UTC 2012
commit 68bdd43edd229174c2afd60b3299c5b041280bba
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Tue Jan 17 13:51:04 2012 +0100
Slowing down in F15. Only a few fixes for bugs reported against F15
StopWhenUnneeded
wtmp
gc of units with load error
...false-positive-in-check-for-unneeded-unit.patch | 54 ++++++++
...nit-garbage-collect-units-with-load-error.patch | 29 ++++
0001-utmp-remove-unneded-parameters.patch | 136 ++++++++++++++++++++
...for-unneeded-dependencies-even-when-unit-.patch | 47 +++++++
...d-to-zero-a-struct-before-overwriting-it-.patch | 26 ++++
...lize-store-with-the-found-entry-not-with-.patch | 26 ++++
...AD_PROCESS-write-the-current-time-to-wtmp.patch | 70 ++++++++++
systemd.spec | 15 ++-
8 files changed, 402 insertions(+), 1 deletions(-)
---
diff --git a/0001-unit-fix-false-positive-in-check-for-unneeded-unit.patch b/0001-unit-fix-false-positive-in-check-for-unneeded-unit.patch
new file mode 100644
index 0000000..97d8d60
--- /dev/null
+++ b/0001-unit-fix-false-positive-in-check-for-unneeded-unit.patch
@@ -0,0 +1,54 @@
+From f60c2665f9ba1dd4a6b4a36b2e8195482ada9957 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Fri, 9 Dec 2011 15:24:04 +0100
+Subject: [PATCH 1/2] unit: fix false positive in check for unneeded unit
+
+A freshly started unit A was immediately considered unneeded just because
+unit B, which Requires A, was starting later in the transaction.
+Fix it by looking not only at the state of B, but also at its pending job.
+
+Also fix a copied&pasted comment.
+---
+ src/unit.c | 10 +++++-----
+ 1 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/unit.c b/src/unit.c
+index 018e986..56137d7 100644
+--- a/src/unit.c
++++ b/src/unit.c
+@@ -1032,19 +1032,19 @@ static void unit_check_unneeded(Unit *u) {
+ return;
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
+- if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
++ if (unit_pending_active(other))
+ return;
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
+- if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
++ if (unit_pending_active(other))
+ return;
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i)
+- if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
++ if (unit_pending_active(other))
+ return;
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
+- if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
++ if (unit_pending_active(other))
+ return;
+
+ log_info("Service %s is not needed anymore. Stopping.", u->meta.id);
+@@ -2518,7 +2518,7 @@ bool unit_pending_inactive(Unit *u) {
+ bool unit_pending_active(Unit *u) {
+ assert(u);
+
+- /* Returns true if the unit is inactive or going down */
++ /* Returns true if the unit is active or going up */
+
+ if (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)))
+ return true;
+--
+1.7.7.5
+
diff --git a/0001-unit-garbage-collect-units-with-load-error.patch b/0001-unit-garbage-collect-units-with-load-error.patch
new file mode 100644
index 0000000..31d2931
--- /dev/null
+++ b/0001-unit-garbage-collect-units-with-load-error.patch
@@ -0,0 +1,29 @@
+From 9a46fc3b9014de1bf0ed1f3004a536b08a19ebb3 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Tue, 6 Dec 2011 00:47:28 +0100
+Subject: [PATCH] unit: garbage collect units with load error
+
+Units that failed to load were never cleaned up. It was possible to
+reach the 128K limit of units by attempting to load a bunch of nonsense.
+
+Bug observed by Reartes Guillermo in
+https://bugzilla.redhat.com/show_bug.cgi?id=680122
+---
+ src/unit.c | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/src/unit.c b/src/unit.c
+index 2a549e2..018e986 100644
+--- a/src/unit.c
++++ b/src/unit.c
+@@ -858,6 +858,7 @@ fail:
+ u->meta.load_state = UNIT_ERROR;
+ u->meta.load_error = r;
+ unit_add_to_dbus_queue(u);
++ unit_add_to_gc_queue(u);
+
+ log_debug("Failed to load configuration for %s: %s", u->meta.id, strerror(-r));
+
+--
+1.7.7.5
+
diff --git a/0001-utmp-remove-unneded-parameters.patch b/0001-utmp-remove-unneded-parameters.patch
new file mode 100644
index 0000000..e68bdb4
--- /dev/null
+++ b/0001-utmp-remove-unneded-parameters.patch
@@ -0,0 +1,136 @@
+From 0ad26e09de813857382ec3a787fc6df5e52cf98b Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Sun, 6 Nov 2011 23:06:38 +0100
+Subject: [PATCH 1/4] utmp: remove unneded parameters
+
+With these functions no caller ever passes anything else than 0
+for 't' (meaning the current time will be used).
+---
+ src/execute.c | 2 +-
+ src/systemctl.c | 2 +-
+ src/update-utmp.c | 4 ++--
+ src/utmp-wtmp.c | 12 ++++++------
+ src/utmp-wtmp.h | 6 +++---
+ 5 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/src/execute.c b/src/execute.c
+index 866e8bf..250d53a 100644
+--- a/src/execute.c
++++ b/src/execute.c
+@@ -1170,7 +1170,7 @@ int exec_spawn(ExecCommand *command,
+ }
+
+ if (context->utmp_id)
+- utmp_put_init_process(0, context->utmp_id, getpid(), getsid(0), context->tty_path);
++ utmp_put_init_process(context->utmp_id, getpid(), getsid(0), context->tty_path);
+
+ if (context->user) {
+ username = context->user;
+diff --git a/src/systemctl.c b/src/systemctl.c
+index 175159d..7373e64 100644
+--- a/src/systemctl.c
++++ b/src/systemctl.c
+@@ -5156,7 +5156,7 @@ static int halt_main(DBusConnection *bus) {
+ if (!arg_no_wtmp) {
+ if (sd_booted() > 0)
+ log_debug("Not writing utmp record, assuming that systemd-update-utmp is used.");
+- else if ((r = utmp_put_shutdown(0)) < 0)
++ else if ((r = utmp_put_shutdown()) < 0)
+ log_warning("Failed to write utmp record: %s", strerror(-r));
+ }
+
+diff --git a/src/update-utmp.c b/src/update-utmp.c
+index 12e4d11..073f28e 100644
+--- a/src/update-utmp.c
++++ b/src/update-utmp.c
+@@ -284,7 +284,7 @@ static int on_shutdown(Context *c) {
+ }
+ #endif
+
+- if ((q = utmp_put_shutdown(0)) < 0) {
++ if ((q = utmp_put_shutdown()) < 0) {
+ log_error("Failed to write utmp record: %s", strerror(-q));
+ r = q;
+ }
+@@ -339,7 +339,7 @@ static int on_runlevel(Context *c) {
+ }
+ #endif
+
+- if ((q = utmp_put_runlevel(0, runlevel, previous)) < 0) {
++ if ((q = utmp_put_runlevel(runlevel, previous)) < 0) {
+ log_error("Failed to write utmp record: %s", strerror(-q));
+ r = q;
+ }
+diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
+index b03a3e7..e7b2e3c 100644
+--- a/src/utmp-wtmp.c
++++ b/src/utmp-wtmp.c
+@@ -172,10 +172,10 @@ static int write_entry_both(const struct utmpx *store) {
+ return r;
+ }
+
+-int utmp_put_shutdown(usec_t t) {
++int utmp_put_shutdown(void) {
+ struct utmpx store;
+
+- init_entry(&store, t);
++ init_entry(&store, 0);
+
+ store.ut_type = RUN_LVL;
+ strncpy(store.ut_user, "shutdown", sizeof(store.ut_user));
+@@ -206,12 +206,12 @@ static const char *sanitize_id(const char *id) {
+ return id + l - sizeof(((struct utmpx*) NULL)->ut_id);
+ }
+
+-int utmp_put_init_process(usec_t t, const char *id, pid_t pid, pid_t sid, const char *line) {
++int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line) {
+ struct utmpx store;
+
+ assert(id);
+
+- init_timestamp(&store, t);
++ init_timestamp(&store, 0);
+
+ store.ut_type = INIT_PROCESS;
+ store.ut_pid = pid;
+@@ -257,7 +257,7 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
+ }
+
+
+-int utmp_put_runlevel(usec_t t, int runlevel, int previous) {
++int utmp_put_runlevel(int runlevel, int previous) {
+ struct utmpx store;
+ int r;
+
+@@ -277,7 +277,7 @@ int utmp_put_runlevel(usec_t t, int runlevel, int previous) {
+ if (previous == runlevel)
+ return 0;
+
+- init_entry(&store, t);
++ init_entry(&store, 0);
+
+ store.ut_type = RUN_LVL;
+ store.ut_pid = (runlevel & 0xFF) | ((previous & 0xFF) << 8);
+diff --git a/src/utmp-wtmp.h b/src/utmp-wtmp.h
+index 4054aff..a5998eb 100644
+--- a/src/utmp-wtmp.h
++++ b/src/utmp-wtmp.h
+@@ -26,12 +26,12 @@
+
+ int utmp_get_runlevel(int *runlevel, int *previous);
+
+-int utmp_put_shutdown(usec_t timestamp);
++int utmp_put_shutdown(void);
+ int utmp_put_reboot(usec_t timestamp);
+-int utmp_put_runlevel(usec_t timestamp, int runlevel, int previous);
++int utmp_put_runlevel(int runlevel, int previous);
+
+ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status);
+-int utmp_put_init_process(usec_t timestamp, const char *id, pid_t pid, pid_t sid, const char *line);
++int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line);
+
+ int utmp_wall(const char *message, bool (*match_tty)(const char *tty));
+
+--
+1.7.7.5
+
diff --git a/0002-unit-check-for-unneeded-dependencies-even-when-unit-.patch b/0002-unit-check-for-unneeded-dependencies-even-when-unit-.patch
new file mode 100644
index 0000000..0ed355e
--- /dev/null
+++ b/0002-unit-check-for-unneeded-dependencies-even-when-unit-.patch
@@ -0,0 +1,47 @@
+From cd0504d0a13d8297b97c9238fd1b94b4141c5aa8 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Fri, 9 Dec 2011 15:25:29 +0100
+Subject: [PATCH 2/2] unit: check for unneeded dependencies even when unit
+ stop was expected
+
+systemd did not stop units marked as "StopWhenUnneeded=yes" when the requiring
+unit was stopped on user's request.
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=704197
+---
+ src/unit.c | 12 ++++++++++++
+ 1 files changed, 12 insertions(+), 0 deletions(-)
+
+diff --git a/src/unit.c b/src/unit.c
+index 56137d7..03c90f5 100644
+--- a/src/unit.c
++++ b/src/unit.c
+@@ -1105,6 +1105,14 @@ static void retroactively_stop_dependencies(Unit *u) {
+ SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
+ if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
+ manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
++}
++
++static void check_unneeded_dependencies(Unit *u) {
++ Iterator i;
++ Unit *other;
++
++ assert(u);
++ assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)));
+
+ /* Garbage collect services that might not be needed anymore, if enabled */
+ SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES], i)
+@@ -1263,6 +1271,10 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
+ retroactively_stop_dependencies(u);
+ }
+
++ /* stop unneeded units regardless if going down was expected or not */
++ if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
++ check_unneeded_dependencies(u);
++
+ if (ns != os && ns == UNIT_FAILED) {
+ log_notice("Unit %s entered failed state.", u->meta.id);
+ unit_trigger_on_failure(u);
+--
+1.7.7.5
+
diff --git a/0002-utmp-no-need-to-zero-a-struct-before-overwriting-it-.patch b/0002-utmp-no-need-to-zero-a-struct-before-overwriting-it-.patch
new file mode 100644
index 0000000..6f2d56f
--- /dev/null
+++ b/0002-utmp-no-need-to-zero-a-struct-before-overwriting-it-.patch
@@ -0,0 +1,26 @@
+From b8e47420b32b52619c6c49c98a663bee7929ccbe Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Sun, 6 Nov 2011 23:07:54 +0100
+Subject: [PATCH 2/4] utmp: no need to zero a struct before overwriting it
+ with memcpy
+
+---
+ src/utmp-wtmp.c | 2 --
+ 1 files changed, 0 insertions(+), 2 deletions(-)
+
+diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
+index e7b2e3c..98c1a25 100644
+--- a/src/utmp-wtmp.c
++++ b/src/utmp-wtmp.c
+@@ -242,8 +242,6 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
+ if (found->ut_pid != pid)
+ return 0;
+
+- zero(store);
+-
+ memcpy(&store, &lookup, sizeof(store));
+ store.ut_type = DEAD_PROCESS;
+ store.ut_exit.e_termination = code;
+--
+1.7.7.5
+
diff --git a/0003-utmp-initialize-store-with-the-found-entry-not-with-.patch b/0003-utmp-initialize-store-with-the-found-entry-not-with-.patch
new file mode 100644
index 0000000..b5cde10
--- /dev/null
+++ b/0003-utmp-initialize-store-with-the-found-entry-not-with-.patch
@@ -0,0 +1,26 @@
+From fa4ad7ceca6c96d9f0b7022819acf8954cba35ea Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Sun, 6 Nov 2011 23:31:46 +0100
+Subject: [PATCH 3/4] utmp: initialize store with the found entry, not with
+ the lookup key
+
+---
+ src/utmp-wtmp.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
+index 98c1a25..00e19a3 100644
+--- a/src/utmp-wtmp.c
++++ b/src/utmp-wtmp.c
+@@ -242,7 +242,7 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
+ if (found->ut_pid != pid)
+ return 0;
+
+- memcpy(&store, &lookup, sizeof(store));
++ memcpy(&store, found, sizeof(store));
+ store.ut_type = DEAD_PROCESS;
+ store.ut_exit.e_termination = code;
+ store.ut_exit.e_exit = status;
+--
+1.7.7.5
+
diff --git a/0004-utmp-for-DEAD_PROCESS-write-the-current-time-to-wtmp.patch b/0004-utmp-for-DEAD_PROCESS-write-the-current-time-to-wtmp.patch
new file mode 100644
index 0000000..dbb155e
--- /dev/null
+++ b/0004-utmp-for-DEAD_PROCESS-write-the-current-time-to-wtmp.patch
@@ -0,0 +1,70 @@
+From 4743137a4b7ce6214a06d02872bdfac080b6f131 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt at redhat.com>
+Date: Sun, 6 Nov 2011 23:55:06 +0100
+Subject: [PATCH 4/4] utmp: for DEAD_PROCESS write the current time to wtmp
+
+Zeroed .ut_tv values in wtmp confuse chkrootkit.
+
+Reported and debugged by Norman Smith. This is based on his patch,
+but modified to behave more like upstart did in F14 and cleaned up.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=743696
+---
+ src/utmp-wtmp.c | 18 +++++++++++++-----
+ 1 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c
+index 00e19a3..217ae1e 100644
+--- a/src/utmp-wtmp.c
++++ b/src/utmp-wtmp.c
+@@ -155,11 +155,11 @@ static int write_entry_wtmp(const struct utmpx *store) {
+ return -errno;
+ }
+
+-static int write_entry_both(const struct utmpx *store) {
++static int write_utmp_wtmp(const struct utmpx *store_utmp, const struct utmpx *store_wtmp) {
+ int r, s;
+
+- r = write_entry_utmp(store);
+- s = write_entry_wtmp(store);
++ r = write_entry_utmp(store_utmp);
++ s = write_entry_wtmp(store_wtmp);
+
+ if (r >= 0)
+ r = s;
+@@ -172,6 +172,10 @@ static int write_entry_both(const struct utmpx *store) {
+ return r;
+ }
+
++static int write_entry_both(const struct utmpx *store) {
++ return write_utmp_wtmp(store, store);
++}
++
+ int utmp_put_shutdown(void) {
+ struct utmpx store;
+
+@@ -226,7 +230,7 @@ int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line
+ }
+
+ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
+- struct utmpx lookup, store, *found;
++ struct utmpx lookup, store, store_wtmp, *found;
+
+ assert(id);
+
+@@ -251,7 +255,11 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
+ zero(store.ut_host);
+ zero(store.ut_tv);
+
+- return write_entry_both(&store);
++ memcpy(&store_wtmp, &store, sizeof(store_wtmp));
++ /* wtmp wants the current time */
++ init_timestamp(&store_wtmp, 0);
++
++ return write_utmp_wtmp(&store, &store_wtmp);
+ }
+
+
+--
+1.7.7.5
+
diff --git a/systemd.spec b/systemd.spec
index f16832f..8d873ab 100644
--- a/systemd.spec
+++ b/systemd.spec
@@ -2,7 +2,7 @@ Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Version: 26
-Release: 13%{?dist}
+Release: 14%{?dist}
License: GPLv2+
Group: System Environment/Base
Summary: A System and Service Manager
@@ -116,6 +116,13 @@ Patch73: 0001-service-don-t-try-to-guess-PID-for-SysV-services-any.patch
Patch74: 0002-manager-fix-a-crash-in-isolating.patch
Patch75: 0001-mount-order-remote-mounts-after-both-network.target-.patch
Patch76: 0001-units-drop-Install-section-from-remote-fs-pre.target.patch
+Patch77: 0001-unit-fix-false-positive-in-check-for-unneeded-unit.patch
+Patch78: 0002-unit-check-for-unneeded-dependencies-even-when-unit-.patch
+Patch79: 0001-utmp-remove-unneded-parameters.patch
+Patch80: 0002-utmp-no-need-to-zero-a-struct-before-overwriting-it-.patch
+Patch81: 0003-utmp-initialize-store-with-the-found-entry-not-with-.patch
+Patch82: 0004-utmp-for-DEAD_PROCESS-write-the-current-time-to-wtmp.patch
+Patch83: 0001-unit-garbage-collect-units-with-load-error.patch
Patch100: fedora-storage-detect-encrypted-PVs.patch
# For sysvinit tools
@@ -378,6 +385,12 @@ fi
%{_bindir}/systemd-sysv-convert
%changelog
+* Tue Jan 17 2012 Michal Schmidt <mschmidt at redhat.com> - 26-14
+- Slowing down in F15. Only a few fixes for bugs reported against F15:
+ - StopWhenUnneeded
+ - wtmp
+ - gc of units with load error
+
* Wed Nov 02 2011 Michal Schmidt <mschmidt at redhat.com> - 26-13
- Fix remote-fs-pre.target and its ordering.
- Fixes: BZ#749940
More information about the scm-commits
mailing list