|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From d81afec1c9bf4b73e3df8996d65ecae95d19b6db Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Lennart Poettering <lennart@poettering.net>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Fri, 22 Aug 2014 18:07:18 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] core: split up "starting" manager state into "initializing"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
and "starting"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
We'll stay in "initializing" until basic.target has reached, at which
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
point we will enter "starting".
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
This is preparation so that we can change the startip timeout to only
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
apply to the first phase of startup, not the full procedure.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/cgroup.c | 4 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/manager.c | 11 +++++++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/manager.h | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
3 files changed, 12 insertions(+), 4 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 9248cb523b..6c6e4f5e7b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/cgroup.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/cgroup.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -300,7 +300,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char buf[MAX(DECIMAL_STR_MAX(unsigned long), DECIMAL_STR_MAX(usec_t)) + 1];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sprintf(buf, "%lu\n",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- state == MANAGER_STARTING && c->startup_cpu_shares != (unsigned long) -1 ? c->startup_cpu_shares :
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING) && c->startup_cpu_shares != (unsigned long) -1 ? c->startup_cpu_shares :
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
c->cpu_shares != (unsigned long) -1 ? c->cpu_shares : 1024);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = cg_set_attribute("cpu", path, "cpu.shares", buf);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -328,7 +328,7 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
CGroupBlockIODeviceBandwidth *b;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!is_root) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- sprintf(buf, "%lu\n", state == MANAGER_STARTING && c->startup_blockio_weight != (unsigned long) -1 ? c->startup_blockio_weight :
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sprintf(buf, "%lu\n", IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING) && c->startup_blockio_weight != (unsigned long) -1 ? c->startup_blockio_weight :
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
c->blockio_weight != (unsigned long) -1 ? c->blockio_weight : 1000);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = cg_set_attribute("blkio", path, "blkio.weight", buf);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/manager.c b/src/core/manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7639aeef19..9abdf475cf 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2837,7 +2837,7 @@ static bool manager_get_show_status(Manager *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (m->no_console_output)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (!IN_SET(manager_state(m), MANAGER_STARTING, MANAGER_STOPPING))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!IN_SET(manager_state(m), MANAGER_INITIALIZING, MANAGER_STARTING, MANAGER_STOPPING))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (m->show_status > 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2928,8 +2928,14 @@ ManagerState manager_state(Manager *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Did we ever finish booting? If not then we are still starting up */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (!dual_timestamp_is_set(&m->finish_timestamp))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!dual_timestamp_is_set(&m->finish_timestamp)) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ u = manager_get_unit(m, SPECIAL_BASIC_TARGET);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!u || !UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u)))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return MANAGER_INITIALIZING;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return MANAGER_STARTING;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Is the special shutdown target queued? If so, we are in shutdown state */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
u = manager_get_unit(m, SPECIAL_SHUTDOWN_TARGET);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2955,6 +2961,7 @@ ManagerState manager_state(Manager *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static const char *const manager_state_table[_MANAGER_STATE_MAX] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ [MANAGER_INITIALIZING] = "initializing",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
[MANAGER_STARTING] = "starting",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
[MANAGER_RUNNING] = "running",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
[MANAGER_DEGRADED] = "degraded",
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/manager.h b/src/core/manager.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7d26c3adea..8e3c146b42 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/manager.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/manager.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -38,6 +38,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
typedef struct Manager Manager;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
typedef enum ManagerState {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ MANAGER_INITIALIZING,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
MANAGER_STARTING,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
MANAGER_RUNNING,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
MANAGER_DEGRADED,
|