richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ff479f
From 38e66bd347619efaa42118ebec55b43a87fe02c6 Mon Sep 17 00:00:00 2001
ff479f
From: Michal Sekletar <msekleta@redhat.com>
ff479f
Date: Mon, 30 May 2022 11:55:41 +0200
ff479f
Subject: [PATCH] unit: check for mount rate limiting before checking active
ff479f
 state
ff479f
ff479f
Having this check as part of mount_can_start() is too late because
ff479f
UNIT(u)->can_start() virtual method is called after checking the active
ff479f
state of unit in unit_start().
ff479f
ff479f
We need to hold off running mount start jobs when /p/s/mountinfo monitor
ff479f
is rate limited even when given mount unit is already active.
ff479f
ff479f
Fixes #20329
ff479f
ff479f
(cherry picked from commit b161bc394b2cc8b271dda9208e310cc2af0cc29d)
ff479f
ff479f
Resolves: #2097336
ff479f
---
ff479f
 src/core/mount.c | 3 ---
ff479f
 src/core/unit.c  | 4 ++++
ff479f
 2 files changed, 4 insertions(+), 3 deletions(-)
ff479f
ff479f
diff --git a/src/core/mount.c b/src/core/mount.c
ff479f
index 9547cb9b29..d37b5731f8 100644
ff479f
--- a/src/core/mount.c
ff479f
+++ b/src/core/mount.c
ff479f
@@ -1999,9 +1999,6 @@ static int mount_can_start(Unit *u) {
ff479f
 
ff479f
         assert(m);
ff479f
 
ff479f
-        if (sd_event_source_is_ratelimited(u->manager->mount_event_source))
ff479f
-                return -EAGAIN;
ff479f
-
ff479f
         r = unit_test_start_limit(u);
ff479f
         if (r < 0) {
ff479f
                 mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT);
ff479f
diff --git a/src/core/unit.c b/src/core/unit.c
ff479f
index c00d30e837..0810bf5a58 100644
ff479f
--- a/src/core/unit.c
ff479f
+++ b/src/core/unit.c
ff479f
@@ -1729,6 +1729,10 @@ int unit_start(Unit *u) {
ff479f
 
ff479f
         assert(u);
ff479f
 
ff479f
+        /* Let's hold off running start jobs for mount units when /proc/self/mountinfo monitor is rate limited. */
ff479f
+        if (u->type == UNIT_MOUNT && sd_event_source_is_ratelimited(u->manager->mount_event_source))
ff479f
+                return -EAGAIN;
ff479f
+
ff479f
         /* If this is already started, then this will succeed. Note that this will even succeed if this unit
ff479f
          * is not startable by the user. This is relied on to detect when we need to wait for units and when
ff479f
          * waiting is finished. */