[systemd-commits] 5 commits - man/systemd.unit.xml src/dbus-unit.h src/load-fragment.c src/manager.c src/mount.c src/service.c src/swap.c src/unit.c src/unit.h src/util.c src/util.h TODO

Lennart Poettering lennart at kemper.freedesktop.org
Wed Oct 27 18:38:59 PDT 2010


 TODO                 |    2 ++
 man/systemd.unit.xml |   22 ++++++++++++----------
 src/dbus-unit.h      |    4 ++--
 src/load-fragment.c  |    2 +-
 src/manager.c        |    4 ++--
 src/mount.c          |    3 +++
 src/service.c        |   51 ++++++++-------------------------------------------
 src/swap.c           |    3 ---
 src/unit.c           |   36 ++++++++++++++++++++----------------
 src/unit.h           |    6 +++---
 src/util.c           |    3 +--
 src/util.h           |    2 +-
 12 files changed, 55 insertions(+), 83 deletions(-)

New commits:
commit f14e15f8affe906a45d8afc76c302a49cd1f70ee
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 28 03:38:52 2010 +0200

    unit: replace recursive_stop by stop_retroactively to simplify things a little

diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index f72b947..14da607 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -441,22 +441,24 @@
                         </varlistentry>
 
                         <varlistentry>
-                                <term><varname>RecursiveStop=</varname></term>
+                                <term><varname>StopRetroactively=</varname></term>
 
                                 <listitem><para>Takes a boolean
                                 argument. If <option>true</option> and
-                                the unit stops without being requested
-                                by the user, all units
-                                depending on it will be stopped as
+                                a unit this unit requires stops
+                                without this being requested by the
+                                user, this unit will be stopped as
                                 well. (e.g. if a service exits or
-                                crashes on its own behalf, units using
-                                it will be stopped) Note that normally
-                                if a unit stops without a user request,
+                                crashes on its own behalf, units this
+                                flag is set for that require it will
+                                be stopped.) Note that normally if a
+                                unit stops without a user request,
                                 units depending on it will not be
                                 terminated. Only if the user requested
-                                shutdown of a unit, all units depending
-                                on that unit will be shut down as well
-                                and at the same time. Defaults to
+                                shutdown of a unit, all units
+                                depending on that unit will be shut
+                                down as well and at the same
+                                time. Defaults to
                                 <option>false</option>.</para></listitem>
                         </varlistentry>
 
diff --git a/src/dbus-unit.h b/src/dbus-unit.h
index 94e084f..4a4d23e 100644
--- a/src/dbus-unit.h
+++ b/src/dbus-unit.h
@@ -92,7 +92,7 @@
         "  <property name=\"CanStop\" type=\"b\" access=\"read\"/>\n"   \
         "  <property name=\"CanIsolate\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Job\" type=\"(uo)\" access=\"read\"/>\n"    \
-        "  <property name=\"RecursiveStop\" type=\"b\" access=\"read\"/>\n" \
+        "  <property name=\"StopRetroactively\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"StopWhenUnneeded\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"RefuseManualStart\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"RefuseManualStop\" type=\"b\" access=\"read\"/>\n" \
@@ -134,7 +134,7 @@
         { "org.freedesktop.systemd1.Unit", "CanReload",            bus_unit_append_can_reload,     "b",    u                                 }, \
         { "org.freedesktop.systemd1.Unit", "CanIsolate",           bus_unit_append_can_isolate,    "b",    u                                 }, \
         { "org.freedesktop.systemd1.Unit", "Job",                  bus_unit_append_job,            "(uo)", u                                 }, \
-        { "org.freedesktop.systemd1.Unit", "RecursiveStop",        bus_property_append_bool,       "b",    &u->meta.recursive_stop           }, \
+        { "org.freedesktop.systemd1.Unit", "StopRetroactively",    bus_property_append_bool,       "b",    &u->meta.stop_retroactively       }, \
         { "org.freedesktop.systemd1.Unit", "StopWhenUnneeded",     bus_property_append_bool,       "b",    &u->meta.stop_when_unneeded       }, \
         { "org.freedesktop.systemd1.Unit", "RefuseManualStart",    bus_property_append_bool,       "b",    &u->meta.refuse_manual_start      }, \
         { "org.freedesktop.systemd1.Unit", "RefuseManualStop",     bus_property_append_bool,       "b",    &u->meta.refuse_manual_stop       }, \
diff --git a/src/device.c b/src/device.c
index 0ddd3b3..7b73110 100644
--- a/src/device.c
+++ b/src/device.c
@@ -69,12 +69,6 @@ static void device_init(Unit *u) {
          * happen for the other units since their operations time out
          * anyway. */
         d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
-
-        /* We enable recursive stopping by default for all
-        devices. This enables the user to use Requires= to make a
-        service go a way when a device goes away, and Wants=
-        otherwise. */
-        d->meta.recursive_stop = true;
 }
 
 static void device_done(Unit *u) {
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 74fe786..bc34451 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1769,7 +1769,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "Before",                 config_parse_deps,            UINT_TO_PTR(UNIT_BEFORE),                        "Unit"    },
                 { "After",                  config_parse_deps,            UINT_TO_PTR(UNIT_AFTER),                         "Unit"    },
                 { "OnFailure",              config_parse_deps,            UINT_TO_PTR(UNIT_ON_FAILURE),                    "Unit"    },
-                { "RecursiveStop",          config_parse_bool,            &u->meta.recursive_stop,                         "Unit"    },
+                { "StopRetroactively",      config_parse_bool,            &u->meta.stop_retroactively,                     "Unit"    },
                 { "StopWhenUnneeded",       config_parse_bool,            &u->meta.stop_when_unneeded,                     "Unit"    },
                 { "RefuseManualStart",      config_parse_bool,            &u->meta.refuse_manual_start,                    "Unit"    },
                 { "RefuseManualStop",       config_parse_bool,            &u->meta.refuse_manual_stop,                     "Unit"    },
diff --git a/src/mount.c b/src/mount.c
index d62ce8f..0b67fbe 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -70,6 +70,9 @@ static void mount_init(Unit *u) {
          * already trying to comply its last one. */
         m->exec_context.same_pgrp = true;
 
+        /* Make sure we unmount when the devices we require go away */
+        m->meta.stop_retroactively = true;
+
         m->timer_watch.type = WATCH_INVALID;
 
         m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
diff --git a/src/unit.c b/src/unit.c
index 1775c1d..f080e7b 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -652,13 +652,13 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (u->meta.load_state == UNIT_LOADED) {
                 fprintf(f,
-                        "%s\tRecursive Stop: %s\n"
+                        "%s\tStopRetroactively: %s\n"
                         "%s\tStopWhenUnneeded: %s\n"
                         "%s\tRefuseManualStart: %s\n"
                         "%s\tRefuseManualStop: %s\n"
                         "%s\tDefaultDependencies: %s\n"
                         "%s\tIgnoreDependencyFailure: %s\n",
-                        prefix, yes_no(u->meta.recursive_stop),
+                        prefix, yes_no(u->meta.stop_retroactively),
                         prefix, yes_no(u->meta.stop_when_unneeded),
                         prefix, yes_no(u->meta.refuse_manual_start),
                         prefix, yes_no(u->meta.refuse_manual_stop),
@@ -1011,12 +1011,11 @@ static void retroactively_stop_dependencies(Unit *u) {
         assert(u);
         assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)));
 
-        if (u->meta.recursive_stop) {
-                /* Pull down units need us recursively if enabled */
-                SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_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);
-        }
+        /* Pull down units which need us recursively if enabled */
+        SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
+                if (other->meta.stop_retroactively &&
+                    !UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
+                        manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
 
         /* Garbage collect services that might not be needed anymore, if enabled */
         SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES], i)
diff --git a/src/unit.h b/src/unit.h
index 3f0ef01..8b6b58e 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -105,7 +105,7 @@ enum UnitDependency {
 
         /* Inverse of the above */
         UNIT_REQUIRED_BY,             /* inverse of 'requires' and 'requisite' is 'required_by' */
-        UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'soft_requires' and 'soft_requisite' is 'soft_required_by' */
+        UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */
         UNIT_WANTED_BY,               /* inverse of 'wants' */
 
         /* Negative dependencies */
@@ -191,8 +191,8 @@ struct Meta {
         /* Error code when we didn't manage to load the unit (negative) */
         int load_error;
 
-        /* If we go down, pull down everything that depends on us, too */
-        bool recursive_stop;
+        /* If some required dep goes down, pull down ourselves, too */
+        bool stop_retroactively;
 
         /* Garbage collect us we nobody wants or requires us anymore */
         bool stop_when_unneeded;

commit 799fd0fd23028a58e1f605c6b0d9aaab65b4fb1f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 28 03:16:03 2010 +0200

    service: unify tstamp serialization code

diff --git a/src/manager.c b/src/manager.c
index 14f18eb..b6a1da7 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -2545,9 +2545,9 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
                         break;
 
                 if (startswith(l, "startup-timestamp="))
-                        dual_timestamp_deserialize(f, l+18, &m->startup_timestamp);
+                        dual_timestamp_deserialize(l+18, &m->startup_timestamp);
                 else if (startswith(l, "finish-timestamp="))
-                        dual_timestamp_deserialize(f, l+17, &m->finish_timestamp);
+                        dual_timestamp_deserialize(l+17, &m->finish_timestamp);
                 else
                         log_debug("Unknown serialization item '%s'", l);
         }
diff --git a/src/service.c b/src/service.c
index 5cf7896..49bdae7 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2299,21 +2299,10 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
 
         if (s->main_exec_status.pid > 0) {
                 unit_serialize_item_format(u, f, "main-exec-status-pid", "%lu", (unsigned long) s->main_exec_status.pid);
+                dual_timestamp_serialize(f, "main-exec-status-start", &s->main_exec_status.start_timestamp);
+                dual_timestamp_serialize(f, "main-exec-status-exit", &s->main_exec_status.exit_timestamp);
 
-                if (s->main_exec_status.start_timestamp.realtime > 0) {
-                        unit_serialize_item_format(u, f, "main-exec-status-start-realtime",
-                                                   "%llu", (unsigned long long) s->main_exec_status.start_timestamp.realtime);
-
-                        unit_serialize_item_format(u, f, "main-exec-status-start-monotonic",
-                                                   "%llu", (unsigned long long) s->main_exec_status.start_timestamp.monotonic);
-                }
-
-                if (s->main_exec_status.exit_timestamp.realtime > 0) {
-                        unit_serialize_item_format(u, f, "main-exec-status-exit-realtime",
-                                                   "%llu", (unsigned long long) s->main_exec_status.exit_timestamp.realtime);
-                        unit_serialize_item_format(u, f, "main-exec-status-exit-monotonic",
-                                                   "%llu", (unsigned long long) s->main_exec_status.exit_timestamp.monotonic);
-
+                if (dual_timestamp_is_set(&s->main_exec_status.exit_timestamp)) {
                         unit_serialize_item_format(u, f, "main-exec-status-code", "%i", s->main_exec_status.code);
                         unit_serialize_item_format(u, f, "main-exec-status-status", "%i", s->main_exec_status.status);
                 }
@@ -2414,35 +2403,11 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
                         log_debug("Failed to parse main-exec-status-status value %s", value);
                 else
                         s->main_exec_status.status = i;
-        } else if (streq(key, "main-exec-status-start-realtime")) {
-                uint64_t k;
-
-                if (safe_atou64(value, &k) < 0)
-                        log_debug("Failed to parse main-exec-status-start-realtime value %s", value);
-                else
-                        s->main_exec_status.start_timestamp.realtime = (usec_t) k;
-        } else if (streq(key, "main-exec-status-start-monotonic")) {
-                uint64_t k;
-
-                if (safe_atou64(value, &k) < 0)
-                        log_debug("Failed to parse main-exec-status-start-monotonic value %s", value);
-                else
-                        s->main_exec_status.start_timestamp.monotonic = (usec_t) k;
-        } else if (streq(key, "main-exec-status-exit-realtime")) {
-                uint64_t k;
-
-                if (safe_atou64(value, &k) < 0)
-                        log_debug("Failed to parse main-exec-status-exit-realtime value %s", value);
-                else
-                        s->main_exec_status.exit_timestamp.realtime = (usec_t) k;
-        } else if (streq(key, "main-exec-status-exit-monotonic")) {
-                uint64_t k;
-
-                if (safe_atou64(value, &k) < 0)
-                        log_debug("Failed to parse main-exec-status-exit-monotonic value %s", value);
-                else
-                        s->main_exec_status.exit_timestamp.monotonic = (usec_t) k;
-        } else
+        } else if (streq(key, "main-exec-status-start"))
+                dual_timestamp_deserialize(value, &s->main_exec_status.start_timestamp);
+        else if (streq(key, "main-exec-status-exit"))
+                dual_timestamp_deserialize(value, &s->main_exec_status.exit_timestamp);
+        else
                 log_debug("Unknown serialization key '%s'", key);
 
         return 0;
diff --git a/src/unit.c b/src/unit.c
index fd9bdae..1775c1d 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -2088,16 +2088,16 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
 
                         continue;
                 } else if (streq(l, "inactive-exit-timestamp")) {
-                        dual_timestamp_deserialize(f, v, &u->meta.inactive_exit_timestamp);
+                        dual_timestamp_deserialize(v, &u->meta.inactive_exit_timestamp);
                         continue;
                 } else if (streq(l, "active-enter-timestamp")) {
-                        dual_timestamp_deserialize(f, v, &u->meta.active_enter_timestamp);
+                        dual_timestamp_deserialize(v, &u->meta.active_enter_timestamp);
                         continue;
                 } else if (streq(l, "active-exit-timestamp")) {
-                        dual_timestamp_deserialize(f, v, &u->meta.active_exit_timestamp);
+                        dual_timestamp_deserialize(v, &u->meta.active_exit_timestamp);
                         continue;
                 } else if (streq(l, "inactive-enter-timestamp")) {
-                        dual_timestamp_deserialize(f, v, &u->meta.inactive_enter_timestamp);
+                        dual_timestamp_deserialize(v, &u->meta.inactive_enter_timestamp);
                         continue;
                 }
 
diff --git a/src/util.c b/src/util.c
index 9a82c71..fecdee1 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3552,10 +3552,9 @@ void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t) {
                 (unsigned long long) t->monotonic);
 }
 
-void dual_timestamp_deserialize(FILE *f, const char *value, dual_timestamp *t) {
+void dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
         unsigned long long a, b;
 
-        assert(f);
         assert(value);
         assert(t);
 
diff --git a/src/util.h b/src/util.h
index 3256fba..b469009 100644
--- a/src/util.h
+++ b/src/util.h
@@ -368,7 +368,7 @@ DIR *xopendirat(int dirfd, const char *name);
 int ask_password_tty(const char *message, usec_t until, const char *flag_file, char **_passphrase);
 
 void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
-void dual_timestamp_deserialize(FILE *f, const char *line, dual_timestamp *t);
+void dual_timestamp_deserialize(const char *value, dual_timestamp *t);
 
 #define NULSTR_FOREACH(i, l) \
         for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)

commit 18f593360bfbce6ab5f74d06a97238ff7171df79
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 28 03:15:44 2010 +0200

    device: set recursive_stop=true by default

diff --git a/TODO b/TODO
index 3f3e54e..67d397e 100644
--- a/TODO
+++ b/TODO
@@ -72,6 +72,8 @@
 
 * only add quotacheck deps to .mount units which mention grpquota/usrquota in the mount flags
 
+* Introduce weaker Conflicts.
+
 External:
 
 * patch kernel for xattr support in /dev, /proc/, /sys and /sys/fs/cgroup.
diff --git a/src/device.c b/src/device.c
index 7b73110..0ddd3b3 100644
--- a/src/device.c
+++ b/src/device.c
@@ -69,6 +69,12 @@ static void device_init(Unit *u) {
          * happen for the other units since their operations time out
          * anyway. */
         d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
+
+        /* We enable recursive stopping by default for all
+        devices. This enables the user to use Requires= to make a
+        service go a way when a device goes away, and Wants=
+        otherwise. */
+        d->meta.recursive_stop = true;
 }
 
 static void device_done(Unit *u) {

commit 8aaf019b5ce1a024090350d881739d28fd3b47d4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 28 02:19:21 2010 +0200

    unit: suppress incorrect deserialization errors

diff --git a/src/unit.c b/src/unit.c
index 0e9325d..fd9bdae 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -2087,14 +2087,19 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
                                 u->meta.deserialized_job = type;
 
                         continue;
-                } else if (streq(l, "inactive-exit-timestamp"))
+                } else if (streq(l, "inactive-exit-timestamp")) {
                         dual_timestamp_deserialize(f, v, &u->meta.inactive_exit_timestamp);
-                else if (streq(l, "active-enter-timestamp"))
+                        continue;
+                } else if (streq(l, "active-enter-timestamp")) {
                         dual_timestamp_deserialize(f, v, &u->meta.active_enter_timestamp);
-                else if (streq(l, "active-exit-timestamp"))
+                        continue;
+                } else if (streq(l, "active-exit-timestamp")) {
                         dual_timestamp_deserialize(f, v, &u->meta.active_exit_timestamp);
-                else if (streq(l, "inactive-enter-timestamp"))
+                        continue;
+                } else if (streq(l, "inactive-enter-timestamp")) {
                         dual_timestamp_deserialize(f, v, &u->meta.inactive_enter_timestamp);
+                        continue;
+                }
 
                 if ((r = UNIT_VTABLE(u)->deserialize_item(u, l, v, fds)) < 0)
                         return r;

commit 008d348eddce97ef807fb908484efb0ade3172c5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 28 01:30:13 2010 +0200

    swap: there's no reason not order swap after sysinit, so drop it

diff --git a/src/swap.c b/src/swap.c
index 4404dc0..078ad9f 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -211,9 +211,6 @@ static int swap_add_default_dependencies(Swap *s) {
 
         if (s->meta.manager->running_as == MANAGER_SYSTEM) {
 
-                if ((r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
-                        return r;
-
                 if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
                         return r;
         }



More information about the systemd-commits mailing list