dryang / rpms / systemd

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