daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
3d3dc8
From dd662fc39a28655b89619a828a15e5e457bf6f4c Mon Sep 17 00:00:00 2001
3d3dc8
From: Michal Sekletar <msekleta@redhat.com>
3d3dc8
Date: Thu, 25 Nov 2021 18:28:25 +0100
3d3dc8
Subject: [PATCH] unit: add jobs that were skipped because of ratelimit back to
3d3dc8
 run_queue
3d3dc8
3d3dc8
Assumption in edc027b was that job we first skipped because of active
3d3dc8
ratelimit is still in run_queue. Hence we trigger the queue and dispatch
3d3dc8
it in the next iteration. Actually we remove jobs from run_queue in
3d3dc8
job_run_and_invalidate() before we call unit_start(). Hence if we want
3d3dc8
to attempt to run the job again in the future we need to add it back
3d3dc8
to run_queue.
3d3dc8
3d3dc8
Fixes #21458
3d3dc8
3d3dc8
(cherry picked from commit c29e6a9530316823b0455cd83eb6d0bb8dd664f4)
3d3dc8
3d3dc8
Related: #2036608
3d3dc8
---
3d3dc8
 src/core/mount.c | 10 ++++++++++
3d3dc8
 1 file changed, 10 insertions(+)
3d3dc8
3d3dc8
diff --git a/src/core/mount.c b/src/core/mount.c
3d3dc8
index c17154cde1..691b23ca74 100644
3d3dc8
--- a/src/core/mount.c
3d3dc8
+++ b/src/core/mount.c
3d3dc8
@@ -1712,9 +1712,19 @@ static bool mount_is_mounted(Mount *m) {
3d3dc8
 
3d3dc8
 static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) {
3d3dc8
         Manager *m = userdata;
3d3dc8
+        Job *j;
3d3dc8
+        Iterator i;
3d3dc8
 
3d3dc8
         assert(m);
3d3dc8
 
3d3dc8
+        /* Let's enqueue all start jobs that were previously skipped because of active ratelimit. */
3d3dc8
+        HASHMAP_FOREACH(j, m->jobs, i) {
3d3dc8
+                if (j->unit->type != UNIT_MOUNT)
3d3dc8
+                        continue;
3d3dc8
+
3d3dc8
+                job_add_to_run_queue(j);
3d3dc8
+        }
3d3dc8
+
3d3dc8
         /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so
3d3dc8
          * let's make sure we dispatch them in the next iteration. */
3d3dc8
         manager_trigger_run_queue(m);