mirror of
https://github.com/systemd/systemd.git
synced 2025-03-29 06:50:16 +03:00
Merge pull request #3709 from poettering/journald-shutdown-sync
journald-related shutdown fixes for slow I/O
This commit is contained in:
commit
20f873deb2
@ -23,6 +23,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "def.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "killall.h"
|
||||
@ -33,8 +34,6 @@
|
||||
#include "terminal-util.h"
|
||||
#include "util.h"
|
||||
|
||||
#define TIMEOUT_USEC (10 * USEC_PER_SEC)
|
||||
|
||||
static bool ignore_proc(pid_t pid, bool warn_rootfs) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
char c;
|
||||
@ -99,7 +98,7 @@ static void wait_for_children(Set *pids, sigset_t *mask) {
|
||||
if (set_isempty(pids))
|
||||
return;
|
||||
|
||||
until = now(CLOCK_MONOTONIC) + TIMEOUT_USEC;
|
||||
until = now(CLOCK_MONOTONIC) + DEFAULT_TIMEOUT_USEC;
|
||||
for (;;) {
|
||||
struct timespec ts;
|
||||
int k;
|
||||
|
@ -157,7 +157,6 @@ static int switch_root_initramfs(void) {
|
||||
return switch_root("/run/initramfs", "/oldroot", false, MS_BIND);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
bool need_umount, need_swapoff, need_loop_detach, need_dm_detach;
|
||||
bool in_container, use_watchdog = false;
|
||||
@ -203,20 +202,25 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
(void) cg_get_root_path(&cgroup);
|
||||
in_container = detect_container() > 0;
|
||||
|
||||
use_watchdog = !!getenv("WATCHDOG_USEC");
|
||||
|
||||
/* lock us into memory */
|
||||
/* Lock us into memory */
|
||||
mlockall(MCL_CURRENT|MCL_FUTURE);
|
||||
|
||||
/* Synchronize everything that is not written to disk yet at this point already. This is a good idea so that
|
||||
* slow IO is processed here already and the final process killing spree is not impacted by processes
|
||||
* desperately trying to sync IO to disk within their timeout. */
|
||||
if (!in_container)
|
||||
sync();
|
||||
|
||||
log_info("Sending SIGTERM to remaining processes...");
|
||||
broadcast_signal(SIGTERM, true, true);
|
||||
|
||||
log_info("Sending SIGKILL to remaining processes...");
|
||||
broadcast_signal(SIGKILL, true, false);
|
||||
|
||||
in_container = detect_container() > 0;
|
||||
|
||||
need_umount = !in_container;
|
||||
need_swapoff = !in_container;
|
||||
need_loop_detach = !in_container;
|
||||
@ -345,10 +349,10 @@ int main(int argc, char *argv[]) {
|
||||
need_loop_detach ? " loop devices," : "",
|
||||
need_dm_detach ? " DM devices," : "");
|
||||
|
||||
/* The kernel will automaticall flush ATA disks and suchlike
|
||||
* on reboot(), but the file systems need to be synce'd
|
||||
* explicitly in advance. So let's do this here, but not
|
||||
* needlessly slow down containers. */
|
||||
/* The kernel will automatically flush ATA disks and suchlike on reboot(), but the file systems need to be
|
||||
* sync'ed explicitly in advance. So let's do this here, but not needlessly slow down containers. Note that we
|
||||
* sync'ed things already once above, but we did some more work since then which might have caused IO, hence
|
||||
* let's doit once more. */
|
||||
if (!in_container)
|
||||
sync();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user