systemd-252-64

Resolves: RHEL-129153,RHEL-131338
This commit is contained in:
Jan Macku 2025-12-12 13:51:43 +01:00
parent f453f2c6ee
commit 1e476f0c70
4 changed files with 183 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From 52defa44074113197a8caade1254a61cfdcfa363 Mon Sep 17 00:00:00 2001
From: Florian Schmaus <flo@geekplace.eu>
Date: Thu, 9 Nov 2023 08:59:59 +0100
Subject: [PATCH] core: fix array size in unit_log_resources()
In 0531bded79dc ("core: include peak memory in unit_log_resources()") new log
messages where added, however the size of the according arrays to hold the
messages was not adjusted.
Fixes: 0531bded79dc ("core: include peak memory in unit_log_resources()")
(cherry picked from commit 893028523469b3ec459388428ddc466942cdaf4d)
Resolves: RHEL-131338
---
src/core/unit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/unit.c b/src/core/unit.c
index afe3fdab04..009f416280 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2242,12 +2242,12 @@ static int raise_level(int log_level, bool condition_info, bool condition_notice
}
static int unit_log_resources(Unit *u) {
- struct iovec iovec[1 + _CGROUP_IP_ACCOUNTING_METRIC_MAX + _CGROUP_IO_ACCOUNTING_METRIC_MAX + 4];
+ struct iovec iovec[1 + 1 + _CGROUP_IP_ACCOUNTING_METRIC_MAX + _CGROUP_IO_ACCOUNTING_METRIC_MAX + 4];
bool any_traffic = false, have_ip_accounting = false, any_io = false, have_io_accounting = false;
_cleanup_free_ char *igress = NULL, *egress = NULL, *rr = NULL, *wr = NULL;
int log_level = LOG_DEBUG; /* May be raised if resources consumed over a threshold */
size_t n_message_parts = 0, n_iovec = 0;
- char* message_parts[1 + 2 + 2 + 1], *t;
+ char* message_parts[1 + 1 + 2 + 2 + 1], *t;
nsec_t nsec = NSEC_INFINITY;
uint64_t memory_peak = UINT64_MAX;
int r;

View File

@ -0,0 +1,63 @@
From 8e0da3f5c5518350215a7186dfa748207ba921e8 Mon Sep 17 00:00:00 2001
From: Luca Boccassi <bluca@debian.org>
Date: Mon, 5 Dec 2022 21:05:54 +0000
Subject: [PATCH] pid1: add env var to override default mount rate limit burst
I am hitting the rate limit on a busy system with low resources, and
it stalls the boot process which is Very Bad (TM).
(cherry picked from commit 24a4542cfa674ee80b54afcc223f2490a011966b)
Related: RHEL-129153
---
docs/ENVIRONMENT.md | 7 +++++++
src/core/mount.c | 11 ++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md
index 54b779d312..88e6f5b372 100644
--- a/docs/ENVIRONMENT.md
+++ b/docs/ENVIRONMENT.md
@@ -281,6 +281,13 @@ All tools:
type as unsupported may not prevent loading some units of that type if they
are referenced by other units of another supported type.
+* `$SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST` — can be set to override the mount
+ units burst rate limit for parsing `/proc/self/mountinfo`. On a system with
+ few resources but many mounts the rate limit may be hit, which will cause the
+ processing of mount units to stall. The burst limit may be adjusted when the
+ default is not appropriate for a given system. Defaults to `5`, accepts
+ positive integers.
+
`systemd-remount-fs`:
* `$SYSTEMD_REMOUNT_ROOT_RW=1` — if set and no entry for the root directory
diff --git a/src/core/mount.c b/src/core/mount.c
index 79772fb6f1..a8e101aa64 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1910,6 +1910,7 @@ static void mount_enumerate(Manager *m) {
mnt_init_debug(0);
if (!m->mount_monitor) {
+ unsigned mount_rate_limit_burst = 5;
int fd;
m->mount_monitor = mnt_new_monitor();
@@ -1949,7 +1950,15 @@ static void mount_enumerate(Manager *m) {
goto fail;
}
- r = sd_event_source_set_ratelimit(m->mount_event_source, 1 * USEC_PER_SEC, 5);
+ /* Let users override the default (5 in 1s), as it stalls the boot sequence on busy systems. */
+ const char *e = secure_getenv("SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST");
+ if (e) {
+ r = safe_atou(e, &mount_rate_limit_burst);
+ if (r < 0)
+ log_debug("Invalid value in $SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST, ignoring: %s", e);
+ }
+
+ r = sd_event_source_set_ratelimit(m->mount_event_source, 1 * USEC_PER_SEC, mount_rate_limit_burst);
if (r < 0) {
log_error_errno(r, "Failed to enable rate limit for mount events: %m");
goto fail;

View File

@ -0,0 +1,75 @@
From 4f880e4dfc1b2e25046be380182535c39a931109 Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Wed, 16 Oct 2024 15:19:09 +0800
Subject: [PATCH] pid1: add env var to override default mount rate limit
interval
Similar to 24a4542c. 24a4542c can only be set 1 in 1s at most,
sometimes we may need to set to something else(such as 1 in 2s).
So it's best to let the user decide.
This also allows users to solve #34690.
(cherry picked from commit cc2030f928981947db8fb9ec185a82024abab2c4)
Related: RHEL-129153
---
docs/ENVIRONMENT.md | 7 +++++++
src/core/mount.c | 14 +++++++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md
index 88e6f5b372..711364a2f7 100644
--- a/docs/ENVIRONMENT.md
+++ b/docs/ENVIRONMENT.md
@@ -288,6 +288,13 @@ All tools:
default is not appropriate for a given system. Defaults to `5`, accepts
positive integers.
+* `$SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_INTERVAL_SEC` — can be set to override the mount
+ units interval rate limit for parsing `/proc/self/mountinfo`. Similar to
+ `$SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST`, the interval limit maybe adjusted when
+ the default is not appropriate for a given system. The default value is 1 and the
+ default application time unit is second, and the time unit can beoverriden as usual
+ by specifying it explicitly, see the systemd.time(7) man page.
+
`systemd-remount-fs`:
* `$SYSTEMD_REMOUNT_ROOT_RW=1` — if set and no entry for the root directory
diff --git a/src/core/mount.c b/src/core/mount.c
index a8e101aa64..be6fbf4cc4 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1910,6 +1910,7 @@ static void mount_enumerate(Manager *m) {
mnt_init_debug(0);
if (!m->mount_monitor) {
+ usec_t mount_rate_limit_interval = 1 * USEC_PER_SEC;
unsigned mount_rate_limit_burst = 5;
int fd;
@@ -1951,14 +1952,21 @@ static void mount_enumerate(Manager *m) {
}
/* Let users override the default (5 in 1s), as it stalls the boot sequence on busy systems. */
- const char *e = secure_getenv("SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST");
+ const char *e = secure_getenv("SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_INTERVAL_SEC");
+ if (e) {
+ r = parse_sec(e, &mount_rate_limit_interval);
+ if (r < 0)
+ log_debug_errno(r, "Invalid value in $SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_INTERVAL_SEC, ignoring: %s", e);
+ }
+
+ e = secure_getenv("SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST");
if (e) {
r = safe_atou(e, &mount_rate_limit_burst);
if (r < 0)
- log_debug("Invalid value in $SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST, ignoring: %s", e);
+ log_debug_errno(r, "Invalid value in $SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST, ignoring: %s", e);
}
- r = sd_event_source_set_ratelimit(m->mount_event_source, 1 * USEC_PER_SEC, mount_rate_limit_burst);
+ r = sd_event_source_set_ratelimit(m->mount_event_source, mount_rate_limit_interval, mount_rate_limit_burst);
if (r < 0) {
log_error_errno(r, "Failed to enable rate limit for mount events: %m");
goto fail;

View File

@ -21,7 +21,7 @@
Name: systemd
Url: https://systemd.io
Version: 252
Release: 63%{?dist}
Release: 64%{?dist}
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: System and Service Manager
@ -1380,6 +1380,9 @@ Patch1294: 1294-cryptsetup-generator-parse-all-cmdline-devices-too.patch
Patch1295: 1295-cryptsetup-generator-always-process-cmdline-devices.patch
Patch1296: 1296-logind-add-background-light-session-class.patch
Patch1297: 1297-pam_systemd-honor-session-class-provided-via-PAM-env.patch
Patch1298: 1298-core-fix-array-size-in-unit_log_resources.patch
Patch1299: 1299-pid1-add-env-var-to-override-default-mount-rate-limi.patch
Patch1300: 1300-pid1-add-env-var-to-override-default-mount-rate-limi.patch
# Downstream-only patches (90009999)
@ -2257,6 +2260,11 @@ systemd-hwdb update &>/dev/null || :
%{_prefix}/lib/dracut/modules.d/70rhel-net-naming-sysattrs/*
%changelog
* Fri Dec 12 2025 systemd maintenance team <systemd-maint@redhat.com> - 252-64
- core: fix array size in unit_log_resources() (RHEL-131338)
- pid1: add env var to override default mount rate limit burst (RHEL-129153)
- pid1: add env var to override default mount rate limit interval (RHEL-129153)
* Thu Nov 27 2025 systemd maintenance team <systemd-maint@redhat.com> - 252-63
- cryptsetup-generator: refactor add_crypttab_devices() (RHEL-127859)
- cryptsetup-generator: continue parsing after error (RHEL-127859)