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