summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_shutdown.c
diff options
context:
space:
mode:
authorluoqi <luoqi@FreeBSD.org>2000-01-07 08:36:44 +0000
committerluoqi <luoqi@FreeBSD.org>2000-01-07 08:36:44 +0000
commite100d44d5538cc21abeba58f459ce9eb497651a9 (patch)
treeca8740d97497e39a1d8bb5f7f15e17f85fa4c506 /sys/kern/kern_shutdown.c
parente69b1ea5c9a5104ae1afe7dd26c89222983ed04e (diff)
downloadFreeBSD-src-e100d44d5538cc21abeba58f459ce9eb497651a9.zip
FreeBSD-src-e100d44d5538cc21abeba58f459ce9eb497651a9.tar.gz
Introduce a mechanism to suspend/resume system processes. Suspend syncer
and bufdaemon prior to disk sync during system shutdown.
Diffstat (limited to 'sys/kern/kern_shutdown.c')
-rw-r--r--sys/kern/kern_shutdown.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index adf02b6..d66cfbd 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -52,6 +52,7 @@
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/kernel.h>
+#include <sys/kthread.h>
#include <sys/mount.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
@@ -571,3 +572,34 @@ poweroff_wait(void *junk, int howto)
return;
DELAY(poweroff_delay * 1000);
}
+
+/*
+ * Some system processes (e.g. syncer) need to be stopped at appropriate
+ * points in their main loops prior to a system shutdown, so that they
+ * won't interfere with the shutdown process (e.g. by holding a disk buf
+ * to cause sync to fail). For each of these system processes, register
+ * shutdown_kproc() as a handler for one of shutdown events.
+ */
+static int kproc_shutdown_wait = 60;
+SYSCTL_INT(_kern_shutdown, OID_AUTO, kproc_shutdown_wait, CTLFLAG_RW,
+ &kproc_shutdown_wait, 0, "");
+
+void
+shutdown_kproc(void *arg, int howto)
+{
+ struct proc *p;
+ int error;
+
+ if (panicstr)
+ return;
+
+ p = (struct proc *)arg;
+ printf("Waiting (max %d seconds) for system process `%s' to stop...",
+ kproc_shutdown_wait * hz, p->p_comm);
+ error = suspend_kproc(p, kproc_shutdown_wait);
+
+ if (error == EWOULDBLOCK)
+ printf("timed out\n");
+ else
+ printf("stopped\n");
+}
OpenPOWER on IntegriCloud