mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-31 17:17:43 +03:00
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 24a4542cfa
)
Included in the backport because it's a workaround for an issue introduced
in v249.
This commit is contained in:
parent
7c0aacc733
commit
c55426445a
@ -268,6 +268,13 @@ All tools:
|
||||
it is either set to `system` or `user` depending on whether the NSS/PAM
|
||||
module is called by systemd in `--system` or `--user` mode.
|
||||
|
||||
* `$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
|
||||
|
@ -1908,6 +1908,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();
|
||||
@ -1947,7 +1948,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;
|
||||
|
Loading…
Reference in New Issue
Block a user