diff options
author | cperciva <cperciva@FreeBSD.org> | 2015-10-08 15:48:44 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2015-10-08 15:48:44 +0000 |
commit | 7b86f845febc3b375bb02008a456a5514a9396c9 (patch) | |
tree | 7d991b1ff89b8bdaf66d6f797ec32d170165cda5 | |
parent | 7ff6dd508c4b1f7e015e548ec82f1bf936b529c0 (diff) | |
download | FreeBSD-src-7b86f845febc3b375bb02008a456a5514a9396c9.zip FreeBSD-src-7b86f845febc3b375bb02008a456a5514a9396c9.tar.gz |
MFC r288446: Disable suspend during shutdown.
-rw-r--r-- | sbin/init/init.c | 14 | ||||
-rw-r--r-- | sys/dev/acpica/acpi.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_shutdown.c | 4 | ||||
-rw-r--r-- | sys/sys/systm.h | 1 |
4 files changed, 24 insertions, 2 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c index 99041c9..e6f567c 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1499,6 +1499,15 @@ static state_func_t death(void) { session_t *sp; + int block, blocked; + size_t len; + + /* Temporarily block suspend. */ + len = sizeof(blocked); + block = 1; + if (sysctlbyname("kern.suspend_blocked", &blocked, &len, + &block, sizeof(block)) == -1) + blocked = 0; /* * Also revoke the TTY here. Because runshutdown() may reopen @@ -1515,6 +1524,11 @@ death(void) /* Try to run the rc.shutdown script within a period of time */ runshutdown(); + /* Unblock suspend if we blocked it. */ + if (!blocked) + sysctlbyname("kern.suspend_blocked", NULL, NULL, + &blocked, sizeof(blocked)); + return (state_func_t) death_single; } diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 107f12d..55b0dd2 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -2546,8 +2546,11 @@ acpi_ReqSleepState(struct acpi_softc *sc, int state) if (!acpi_sleep_states[state]) return (EOPNOTSUPP); - /* If a suspend request is already in progress, just return. */ - if (sc->acpi_next_sstate != 0) { + /* + * If a reboot/shutdown/suspend request is already in progress or + * suspend is blocked due to an upcoming shutdown, just return. + */ + if (rebooting || sc->acpi_next_sstate != 0 || suspend_blocked) { return (0); } diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index f3b3c30..55fee01 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -139,6 +139,10 @@ static int show_busybufs = 1; SYSCTL_INT(_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW, &show_busybufs, 0, ""); +int suspend_blocked = 0; +SYSCTL_INT(_kern, OID_AUTO, suspend_blocked, CTLFLAG_RW, + &suspend_blocked, 0, "Block suspend due to a pending shutdown"); + /* * Variable panicstr contains argument to first call to panic; used as flag * to indicate that the kernel has already called panic. diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 9bf3ffa..cb83ba4 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -46,6 +46,7 @@ #include <sys/stdint.h> /* for people using printf mainly */ extern int cold; /* nonzero if we are doing a cold boot */ +extern int suspend_blocked; /* block suspend due to pending shutdown */ extern int rebooting; /* kern_reboot() has been called. */ extern const char *panicstr; /* panic message */ extern char version[]; /* system version */ |