]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit: check for mount rate limiting before checking active state
authorMichal Sekletar <msekleta@redhat.com>
Mon, 30 May 2022 09:55:41 +0000 (11:55 +0200)
committerMichal Sekletar <msekleta@redhat.com>
Mon, 30 May 2022 11:22:16 +0000 (13:22 +0200)
Having this check as part of mount_can_start() is too late because
UNIT(u)->can_start() virtual method is called after checking the active
state of unit in unit_start().

We need to hold off running mount start jobs when /p/s/mountinfo monitor
is rate limited even when given mount unit is already active.

Fixes #20329

src/core/mount.c
src/core/unit.c

index 20b4bb6d2b8116c60df3e9ae189ab3d4f2e8b60b..a2fd9c2a993296fe330f964150edd2da3b9cc949 100644 (file)
@@ -2170,9 +2170,6 @@ static int mount_can_start(Unit *u) {
 
         assert(m);
 
-        if (sd_event_source_is_ratelimited(u->manager->mount_event_source))
-                return -EAGAIN;
-
         r = unit_test_start_limit(u);
         if (r < 0) {
                 mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT);
index b0756bc6f43bfd2ff01db18f1dd7517c1455d7e0..d7f5245ca3bb751ab89f62225b3aaae237f9dd79 100644 (file)
@@ -1868,6 +1868,10 @@ int unit_start(Unit *u) {
 
         assert(u);
 
+        /* Let's hold off running start jobs for mount units when /proc/self/mountinfo monitor is rate limited. */
+        if (u->type == UNIT_MOUNT && sd_event_source_is_ratelimited(u->manager->mount_event_source))
+                return -EAGAIN;
+
         /* If this is already started, then this will succeed. Note that this will even succeed if this unit
          * is not startable by the user. This is relied on to detect when we need to wait for units and when
          * waiting is finished. */