dcavalca / rpms / systemd

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