]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: rename/generalize UNIT(u)->test_start_limit() hook
authorMichal Sekletar <msekleta@redhat.com>
Mon, 4 Oct 2021 15:51:52 +0000 (17:51 +0200)
committerMichal Sekletar <msekleta@redhat.com>
Thu, 11 Nov 2021 16:04:36 +0000 (17:04 +0100)
Up until now the main reason why we didn't proceed with starting the
unit was exceed start limit burst. However, for unit types like mounts
the other reason could be effective ratelimit on /proc/self/mountinfo
event source. That means our mount unit state may not reflect current
kernel state. Hence, we need to attempt to re-run the start job again
after ratelimit on event source expires.

As we will be introducing another reason than start limit let's rename
the virtual function that implements the check.

src/core/automount.c
src/core/mount.c
src/core/path.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/timer.c
src/core/unit.c
src/core/unit.h

index de470935c7fe859fa4bc8b76cd67b546c24312a0..1fc3fc0f82736365c6d533bfcc647491d754adfb 100644 (file)
@@ -1063,7 +1063,7 @@ static bool automount_supported(void) {
         return supported;
 }
 
-static int automount_test_start_limit(Unit *u) {
+static int automount_can_start(Unit *u) {
         Automount *a = AUTOMOUNT(u);
         int r;
 
@@ -1075,7 +1075,7 @@ static int automount_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = {
@@ -1142,5 +1142,5 @@ const UnitVTable automount_vtable = {
                 },
         },
 
-        .test_start_limit = automount_test_start_limit,
+        .can_start = automount_can_start,
 };
index 321c7986b3ccc39365baa969534e468f08859359..2ebae752b64420f9d6296abea130674e1bb229be 100644 (file)
@@ -2135,7 +2135,7 @@ static int mount_can_clean(Unit *u, ExecCleanMask *ret) {
         return exec_context_get_clean_mask(&m->exec_context, ret);
 }
 
-static int mount_test_start_limit(Unit *u) {
+static int mount_can_start(Unit *u) {
         Mount *m = MOUNT(u);
         int r;
 
@@ -2147,7 +2147,7 @@ static int mount_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
@@ -2248,5 +2248,5 @@ const UnitVTable mount_vtable = {
                 },
         },
 
-        .test_start_limit = mount_test_start_limit,
+        .can_start = mount_can_start,
 };
index 0a3d86e9dbd04995eec8c6b574be4dc13a263ebd..cdab9dcf8c624bf90479b6189edb2ea722e8eceb 100644 (file)
@@ -811,7 +811,7 @@ static void path_reset_failed(Unit *u) {
         p->result = PATH_SUCCESS;
 }
 
-static int path_test_start_limit(Unit *u) {
+static int path_can_start(Unit *u) {
         Path *p = PATH(u);
         int r;
 
@@ -823,7 +823,7 @@ static int path_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const path_type_table[_PATH_TYPE_MAX] = {
@@ -882,5 +882,5 @@ const UnitVTable path_vtable = {
 
         .bus_set_property = bus_path_set_property,
 
-        .test_start_limit = path_test_start_limit,
+        .can_start = path_can_start,
 };
index 83cbc9f4894bc78e6dd85b81f06889ba14e51c96..17c19a2c4ab54196f23553a2bc3300bf68d79f70 100644 (file)
@@ -4482,7 +4482,7 @@ static const char *service_finished_job(Unit *u, JobType t, JobResult result) {
         return NULL;
 }
 
-static int service_test_start_limit(Unit *u) {
+static int service_can_start(Unit *u) {
         Service *s = SERVICE(u);
         int r;
 
@@ -4495,7 +4495,7 @@ static int service_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const service_restart_table[_SERVICE_RESTART_MAX] = {
@@ -4669,5 +4669,5 @@ const UnitVTable service_vtable = {
                 .finished_job = service_finished_job,
         },
 
-        .test_start_limit = service_test_start_limit,
+        .can_start = service_can_start,
 };
index 6534311bef249ce92511020c8d19805689035046..f265aab5948d8f04ecf76458a6518d43de3f69b5 100644 (file)
@@ -3427,7 +3427,7 @@ static int socket_can_clean(Unit *u, ExecCleanMask *ret) {
         return exec_context_get_clean_mask(&s->exec_context, ret);
 }
 
-static int socket_test_start_limit(Unit *u) {
+static int socket_can_start(Unit *u) {
         Socket *s = SOCKET(u);
         int r;
 
@@ -3439,7 +3439,7 @@ static int socket_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const socket_exec_command_table[_SOCKET_EXEC_COMMAND_MAX] = {
@@ -3570,5 +3570,5 @@ const UnitVTable socket_vtable = {
                 },
         },
 
-        .test_start_limit = socket_test_start_limit,
+        .can_start = socket_can_start,
 };
index de72ac9232ad58a162834ad4133761418dda3a40..3b28235194d27a7bc8b724e1c5330d19ac3e5203 100644 (file)
@@ -1581,7 +1581,7 @@ static int swap_can_clean(Unit *u, ExecCleanMask *ret) {
         return exec_context_get_clean_mask(&s->exec_context, ret);
 }
 
-static int swap_test_start_limit(Unit *u) {
+static int swap_can_start(Unit *u) {
         Swap *s = SWAP(u);
         int r;
 
@@ -1593,7 +1593,7 @@ static int swap_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const swap_exec_command_table[_SWAP_EXEC_COMMAND_MAX] = {
@@ -1692,5 +1692,5 @@ const UnitVTable swap_vtable = {
                 },
         },
 
-        .test_start_limit = swap_test_start_limit,
+        .can_start = swap_can_start,
 };
index 240a2f473ba2ff45e2aab11b2b5da6ba71fe5a67..b22168fad57705a9c294f5b37f8854762971e4d5 100644 (file)
@@ -889,7 +889,7 @@ static int timer_can_clean(Unit *u, ExecCleanMask *ret) {
         return 0;
 }
 
-static int timer_test_start_limit(Unit *u) {
+static int timer_can_start(Unit *u) {
         Timer *t = TIMER(u);
         int r;
 
@@ -901,7 +901,7 @@ static int timer_test_start_limit(Unit *u) {
                 return r;
         }
 
-        return 0;
+        return 1;
 }
 
 static const char* const timer_base_table[_TIMER_BASE_MAX] = {
@@ -965,5 +965,5 @@ const UnitVTable timer_vtable = {
 
         .bus_set_property = bus_timer_set_property,
 
-        .test_start_limit = timer_test_start_limit,
+        .can_start = timer_can_start,
 };
index 77d4ceaf2421dcf8b7472a5d0f90813fc9c50ae4..929cc85e13b206fd299135eacedb618bba4295fb 100644 (file)
@@ -1904,9 +1904,9 @@ int unit_start(Unit *u) {
                 return unit_start(following);
         }
 
-        /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */
-        if (UNIT_VTABLE(u)->test_start_limit) {
-                r = UNIT_VTABLE(u)->test_start_limit(u);
+        /* Check our ability to start early so that failure conditions don't cause us to enter a busy loop. */
+        if (UNIT_VTABLE(u)->can_start) {
+                r = UNIT_VTABLE(u)->can_start(u);
                 if (r < 0)
                         return r;
         }
index 3f3a75d33b37c8527975eea0fdb9ca4a803bf680..76701519c2c7ffcfaf345cbb6552f7fc9bc16a80 100644 (file)
@@ -665,7 +665,7 @@ typedef struct UnitVTable {
 
         /* If this function is set, it's invoked first as part of starting a unit to allow start rate
          * limiting checks to occur before we do anything else. */
-        int (*test_start_limit)(Unit *u);
+        int (*can_start)(Unit *u);
 
         /* The strings to print in status messages */
         UnitStatusMessageFormats status_message_formats;