teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0696-mount-retrigger-run-queue-after-ratelimit-expired-to.patch

be0c12
From b0c226e9fd3e6bfa5388832cc2745d9ec935f3ec Mon Sep 17 00:00:00 2001
be0c12
From: Michal Sekletar <msekleta@redhat.com>
be0c12
Date: Mon, 4 Oct 2021 20:31:49 +0200
be0c12
Subject: [PATCH] mount: retrigger run queue after ratelimit expired to run
be0c12
 delayed mount start jobs
be0c12
be0c12
Fixes #20329
be0c12
be0c12
(cherry picked from commit edc027b4f1cfaa49e8ecdde763eb8c623402d464)
be0c12
be0c12
Related: #2036608
be0c12
---
be0c12
 src/core/mount.c | 21 +++++++++++++++++++++
be0c12
 1 file changed, 21 insertions(+)
be0c12
be0c12
diff --git a/src/core/mount.c b/src/core/mount.c
be0c12
index ab09e6fbb0..bdba9e6884 100644
be0c12
--- a/src/core/mount.c
be0c12
+++ b/src/core/mount.c
be0c12
@@ -1710,6 +1710,21 @@ static bool mount_is_mounted(Mount *m) {
be0c12
         return UNIT(m)->perpetual || m->is_mounted;
be0c12
 }
be0c12
 
be0c12
+static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) {
be0c12
+        Manager *m = userdata;
be0c12
+        int r;
be0c12
+
be0c12
+        assert(m);
be0c12
+
be0c12
+        /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so let's
be0c12
+         * make sure we dispatch them in the next iteration. */
be0c12
+        r = sd_event_source_set_enabled(m->run_queue_event_source, SD_EVENT_ONESHOT);
be0c12
+        if (r < 0)
be0c12
+                log_debug_errno(r, "Failed to enable run queue event source, ignoring: %m");
be0c12
+
be0c12
+        return 0;
be0c12
+}
be0c12
+
be0c12
 static void mount_enumerate(Manager *m) {
be0c12
         int r;
be0c12
 
be0c12
@@ -1763,6 +1778,12 @@ static void mount_enumerate(Manager *m) {
be0c12
                         goto fail;
be0c12
                 }
be0c12
 
be0c12
+                r = sd_event_source_set_ratelimit_expire_callback(m->mount_event_source, mount_on_ratelimit_expire);
be0c12
+                if (r < 0) {
be0c12
+                         log_error_errno(r, "Failed to enable rate limit for mount events: %m");
be0c12
+                         goto fail;
be0c12
+                }
be0c12
+
be0c12
                 (void) sd_event_source_set_description(m->mount_event_source, "mount-monitor-dispatch");
be0c12
         }
be0c12