|
|
17aa40 |
From 3674514b7220a136dcfd464c205d41609f0c99a7 Mon Sep 17 00:00:00 2001
|
|
|
eb8b6e |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
eb8b6e |
Date: Mon, 4 Oct 2021 17:51:52 +0200
|
|
|
eb8b6e |
Subject: [PATCH] core: rename/generalize UNIT(u)->test_start_limit() hook
|
|
|
eb8b6e |
|
|
|
eb8b6e |
Up until now the main reason why we didn't proceed with starting the
|
|
|
eb8b6e |
unit was exceed start limit burst. However, for unit types like mounts
|
|
|
eb8b6e |
the other reason could be effective ratelimit on /proc/self/mountinfo
|
|
|
eb8b6e |
event source. That means our mount unit state may not reflect current
|
|
|
eb8b6e |
kernel state. Hence, we need to attempt to re-run the start job again
|
|
|
eb8b6e |
after ratelimit on event source expires.
|
|
|
eb8b6e |
|
|
|
eb8b6e |
As we will be introducing another reason than start limit let's rename
|
|
|
eb8b6e |
the virtual function that implements the check.
|
|
|
eb8b6e |
|
|
|
eb8b6e |
(cherry picked from commit 705578c3b9d794097233aa66010cf67b2a444716)
|
|
|
eb8b6e |
|
|
|
17aa40 |
Related: #2036608
|
|
|
eb8b6e |
---
|
|
|
eb8b6e |
src/core/automount.c | 6 +++---
|
|
|
eb8b6e |
src/core/mount.c | 6 +++---
|
|
|
eb8b6e |
src/core/path.c | 6 +++---
|
|
|
eb8b6e |
src/core/service.c | 6 +++---
|
|
|
eb8b6e |
src/core/socket.c | 6 +++---
|
|
|
eb8b6e |
src/core/swap.c | 6 +++---
|
|
|
eb8b6e |
src/core/timer.c | 6 +++---
|
|
|
eb8b6e |
src/core/unit.c | 6 +++---
|
|
|
eb8b6e |
src/core/unit.h | 2 +-
|
|
|
eb8b6e |
9 files changed, 25 insertions(+), 25 deletions(-)
|
|
|
eb8b6e |
|
|
|
eb8b6e |
diff --git a/src/core/automount.c b/src/core/automount.c
|
|
|
eb8b6e |
index 5e16adabb5..f212620c8f 100644
|
|
|
eb8b6e |
--- a/src/core/automount.c
|
|
|
eb8b6e |
+++ b/src/core/automount.c
|
|
|
eb8b6e |
@@ -1071,7 +1071,7 @@ static bool automount_supported(void) {
|
|
|
eb8b6e |
return supported;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int automount_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int automount_can_start(Unit *u) {
|
|
|
eb8b6e |
Automount *a = AUTOMOUNT(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
@@ -1083,7 +1083,7 @@ static int automount_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = {
|
|
|
eb8b6e |
@@ -1145,5 +1145,5 @@ const UnitVTable automount_vtable = {
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- .test_start_limit = automount_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = automount_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
|
17aa40 |
index 22848847e5..032a2ca156 100644
|
|
|
eb8b6e |
--- a/src/core/mount.c
|
|
|
eb8b6e |
+++ b/src/core/mount.c
|
|
|
17aa40 |
@@ -1951,7 +1951,7 @@ static int mount_control_pid(Unit *u) {
|
|
|
eb8b6e |
return m->control_pid;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int mount_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int mount_can_start(Unit *u) {
|
|
|
eb8b6e |
Mount *m = MOUNT(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
17aa40 |
@@ -1963,7 +1963,7 @@ static int mount_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
|
|
|
17aa40 |
@@ -2058,5 +2058,5 @@ const UnitVTable mount_vtable = {
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- .test_start_limit = mount_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = mount_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/path.c b/src/core/path.c
|
|
|
eb8b6e |
index 1e69a1f05f..58f490589d 100644
|
|
|
eb8b6e |
--- a/src/core/path.c
|
|
|
eb8b6e |
+++ b/src/core/path.c
|
|
|
eb8b6e |
@@ -724,7 +724,7 @@ static void path_reset_failed(Unit *u) {
|
|
|
eb8b6e |
p->result = PATH_SUCCESS;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int path_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int path_can_start(Unit *u) {
|
|
|
eb8b6e |
Path *p = PATH(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
@@ -736,7 +736,7 @@ static int path_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const path_type_table[_PATH_TYPE_MAX] = {
|
|
|
eb8b6e |
@@ -792,5 +792,5 @@ const UnitVTable path_vtable = {
|
|
|
eb8b6e |
.bus_vtable = bus_path_vtable,
|
|
|
eb8b6e |
.bus_set_property = bus_path_set_property,
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- .test_start_limit = path_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = path_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/service.c b/src/core/service.c
|
|
|
17aa40 |
index c5f408d817..e8ae1a5772 100644
|
|
|
eb8b6e |
--- a/src/core/service.c
|
|
|
eb8b6e |
+++ b/src/core/service.c
|
|
|
17aa40 |
@@ -4074,7 +4074,7 @@ static bool service_needs_console(Unit *u) {
|
|
|
eb8b6e |
SERVICE_FINAL_SIGKILL);
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int service_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int service_can_start(Unit *u) {
|
|
|
eb8b6e |
Service *s = SERVICE(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
17aa40 |
@@ -4087,7 +4087,7 @@ static int service_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const service_restart_table[_SERVICE_RESTART_MAX] = {
|
|
|
17aa40 |
@@ -4232,5 +4232,5 @@ const UnitVTable service_vtable = {
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- .test_start_limit = service_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = service_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/socket.c b/src/core/socket.c
|
|
|
eb8b6e |
index 36d2e4f823..3589300e68 100644
|
|
|
eb8b6e |
--- a/src/core/socket.c
|
|
|
eb8b6e |
+++ b/src/core/socket.c
|
|
|
eb8b6e |
@@ -3261,7 +3261,7 @@ static int socket_control_pid(Unit *u) {
|
|
|
eb8b6e |
return s->control_pid;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int socket_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int socket_can_start(Unit *u) {
|
|
|
eb8b6e |
Socket *s = SOCKET(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
@@ -3273,7 +3273,7 @@ static int socket_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const socket_exec_command_table[_SOCKET_EXEC_COMMAND_MAX] = {
|
|
|
eb8b6e |
@@ -3369,5 +3369,5 @@ const UnitVTable socket_vtable = {
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- .test_start_limit = socket_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = socket_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/swap.c b/src/core/swap.c
|
|
|
eb8b6e |
index 90fcd69300..498c5a6d69 100644
|
|
|
eb8b6e |
--- a/src/core/swap.c
|
|
|
eb8b6e |
+++ b/src/core/swap.c
|
|
|
eb8b6e |
@@ -1452,7 +1452,7 @@ static int swap_control_pid(Unit *u) {
|
|
|
eb8b6e |
return s->control_pid;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int swap_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int swap_can_start(Unit *u) {
|
|
|
eb8b6e |
Swap *s = SWAP(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
@@ -1464,7 +1464,7 @@ static int swap_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const swap_exec_command_table[_SWAP_EXEC_COMMAND_MAX] = {
|
|
|
eb8b6e |
@@ -1557,5 +1557,5 @@ const UnitVTable swap_vtable = {
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
},
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- .test_start_limit = swap_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = swap_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/timer.c b/src/core/timer.c
|
|
|
eb8b6e |
index fb9ae17990..684180bf99 100644
|
|
|
eb8b6e |
--- a/src/core/timer.c
|
|
|
eb8b6e |
+++ b/src/core/timer.c
|
|
|
eb8b6e |
@@ -823,7 +823,7 @@ static void timer_timezone_change(Unit *u) {
|
|
|
eb8b6e |
timer_enter_waiting(t, false);
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
-static int timer_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
+static int timer_can_start(Unit *u) {
|
|
|
eb8b6e |
Timer *t = TIMER(u);
|
|
|
eb8b6e |
int r;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
@@ -835,7 +835,7 @@ static int timer_test_start_limit(Unit *u) {
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- return 0;
|
|
|
eb8b6e |
+ return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static const char* const timer_base_table[_TIMER_BASE_MAX] = {
|
|
|
eb8b6e |
@@ -893,5 +893,5 @@ const UnitVTable timer_vtable = {
|
|
|
eb8b6e |
.bus_set_property = bus_timer_set_property,
|
|
|
eb8b6e |
|
|
|
eb8b6e |
.can_transient = true,
|
|
|
eb8b6e |
- .test_start_limit = timer_test_start_limit,
|
|
|
eb8b6e |
+ .can_start = timer_can_start,
|
|
|
eb8b6e |
};
|
|
|
eb8b6e |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
17aa40 |
index f0df7452fa..4de218feac 100644
|
|
|
eb8b6e |
--- a/src/core/unit.c
|
|
|
eb8b6e |
+++ b/src/core/unit.c
|
|
|
17aa40 |
@@ -1728,9 +1728,9 @@ int unit_start(Unit *u) {
|
|
|
eb8b6e |
|
|
|
eb8b6e |
assert(u);
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */
|
|
|
eb8b6e |
- if (UNIT_VTABLE(u)->test_start_limit) {
|
|
|
eb8b6e |
- int r = UNIT_VTABLE(u)->test_start_limit(u);
|
|
|
eb8b6e |
+ /* Check our ability to start early so that failure conditions don't cause us to enter a busy loop. */
|
|
|
eb8b6e |
+ if (UNIT_VTABLE(u)->can_start) {
|
|
|
eb8b6e |
+ int r = UNIT_VTABLE(u)->can_start(u);
|
|
|
eb8b6e |
if (r < 0)
|
|
|
eb8b6e |
return r;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
diff --git a/src/core/unit.h b/src/core/unit.h
|
|
|
eb8b6e |
index 9e6f1bcf81..0cd259411f 100644
|
|
|
eb8b6e |
--- a/src/core/unit.h
|
|
|
eb8b6e |
+++ b/src/core/unit.h
|
|
|
eb8b6e |
@@ -569,7 +569,7 @@ typedef struct UnitVTable {
|
|
|
eb8b6e |
|
|
|
eb8b6e |
/* If this function is set, it's invoked first as part of starting a unit to allow start rate
|
|
|
eb8b6e |
* limiting checks to occur before we do anything else. */
|
|
|
eb8b6e |
- int (*test_start_limit)(Unit *u);
|
|
|
eb8b6e |
+ int (*can_start)(Unit *u);
|
|
|
eb8b6e |
|
|
|
eb8b6e |
/* The strings to print in status messages */
|
|
|
eb8b6e |
UnitStatusMessageFormats status_message_formats;
|