Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Dec 2015 14:17:07 +0000 (UTC)
From:      Steven Hartland <smh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292266 - head/sbin/reboot
Message-ID:  <201512151417.tBFEH7i3055359@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: smh
Date: Tue Dec 15 14:17:07 2015
New Revision: 292266
URL: https://svnweb.freebsd.org/changeset/base/292266

Log:
  Add flag to disable inital reboot(8) userland sync
  
  Add -N flag to reboot(8) which bypasses the userland sync(2) during
  reboot(8) while still allow the kernel sync during the reboot(2) syscall
  to occur.
  
  An example use of this is when rebooting with disconnected iSCSI sessions
  which would otherwise cause the reboot to hang on BIOs that will never
  complete.
  
  Reviewed by:	bjk
  MFC after:	2 weeks
  Sponsored by:	Multiplay
  Differential Revision:	https://reviews.freebsd.org/D4449

Modified:
  head/sbin/reboot/reboot.8
  head/sbin/reboot/reboot.c

Modified: head/sbin/reboot/reboot.8
==============================================================================
--- head/sbin/reboot/reboot.8	Tue Dec 15 13:29:05 2015	(r292265)
+++ head/sbin/reboot/reboot.8	Tue Dec 15 14:17:07 2015	(r292266)
@@ -28,7 +28,7 @@
 .\"	@(#)reboot.8	8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd May 22, 2015
+.Dd Dec 12, 2015
 .Dt REBOOT 8
 .Os
 .Sh NAME
@@ -39,16 +39,16 @@
 .Nd stopping and restarting the system
 .Sh SYNOPSIS
 .Nm halt
-.Op Fl lnpq
+.Op Fl lNnpq
 .Op Fl k Ar kernel
 .Nm
-.Op Fl dlnpqr
+.Op Fl dlNnpqr
 .Op Fl k Ar kernel
 .Nm fasthalt
-.Op Fl lnpq
+.Op Fl lNnpq
 .Op Fl k Ar kernel
 .Nm fastboot
-.Op Fl dlnpq
+.Op Fl dlNnpq
 .Op Fl k Ar kernel
 .Sh DESCRIPTION
 The
@@ -94,6 +94,16 @@ that call
 or
 .Nm halt
 and log this themselves.
+.It Fl N
+The file system cache is not flushed during the initial process clean-up,
+however the kernel level
+.Xr reboot 2
+is still processed with a sync.
+This option can be useful for performing a
+.Dq best-effort
+reboot when devices might be unavailable.
+This can happen when devices have been disconnected, such as with
+.Xr iscsi 4 .
 .It Fl n
 The file system cache is not flushed.
 This option should probably not be used.

Modified: head/sbin/reboot/reboot.c
==============================================================================
--- head/sbin/reboot/reboot.c	Tue Dec 15 13:29:05 2015	(r292265)
+++ head/sbin/reboot/reboot.c	Tue Dec 15 14:17:07 2015	(r292266)
@@ -67,7 +67,7 @@ main(int argc, char *argv[])
 {
 	struct utmpx utx;
 	const struct passwd *pw;
-	int ch, howto, i, fd, lflag, nflag, qflag, sverrno;
+	int ch, howto, i, fd, lflag, nflag, qflag, sverrno, Nflag;
 	u_int pageins;
 	const char *user, *kernel = NULL;
 
@@ -77,7 +77,7 @@ main(int argc, char *argv[])
 	} else
 		howto = 0;
 	lflag = nflag = qflag = 0;
-	while ((ch = getopt(argc, argv, "dk:lnpqr")) != -1)
+	while ((ch = getopt(argc, argv, "dk:lNnpqr")) != -1)
 		switch(ch) {
 		case 'd':
 			howto |= RB_DUMP;
@@ -92,6 +92,10 @@ main(int argc, char *argv[])
 			nflag = 1;
 			howto |= RB_NOSYNC;
 			break;
+		case 'N':
+			nflag = 1;
+			Nflag = 1;
+			break;
 		case 'p':
 			howto |= RB_POWEROFF;
 			break;
@@ -110,6 +114,8 @@ main(int argc, char *argv[])
 
 	if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT))
 		errx(1, "cannot dump (-d) when halting; must reboot instead");
+	if (Nflag && (howto & RB_NOSYNC) != 0)
+		errx(1, "-N cannot be used with -n");
 	if ((howto & RB_REROOT) != 0 && howto != RB_REROOT)
 		errx(1, "-r cannot be used with -d, -n, or -p");
 	if (geteuid()) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512151417.tBFEH7i3055359>