Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Oct 2012 00:17:16 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241568 - head/usr.sbin/mountd
Message-ID:  <201210150017.q9F0HGOl072847@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon Oct 15 00:17:16 2012
New Revision: 241568
URL: http://svn.freebsd.org/changeset/base/241568

Log:
  Add a new '-S' option to mountd, which tells it to suspend
  execution of the nfsd threads while it is reloading the exports.
  This avoids clients from getting intermittent access errors
  when the exports are being reloaded non-atomically.
  It is not an ideal solution, since requests will back up while
  the nfsd threads are suspended. Also, when this option is used,
  if mountd crashes while reloading exports, mountd will have to
  be restarted to get the nfsd threads to resume execution.
  This has been tested by Vincent Hoffman (vince at unsane.co.uk)
  and John Hickey (jh at deterlab.net).
  The nfse patch offers a more comprehensive solution for this issue.
  
  PR:		kern/9619, kern/131342
  Reviewed by:	kib
  MFC after:	2 weeks

Modified:
  head/usr.sbin/mountd/mountd.c

Modified: head/usr.sbin/mountd/mountd.c
==============================================================================
--- head/usr.sbin/mountd/mountd.c	Mon Oct 15 00:07:18 2012	(r241567)
+++ head/usr.sbin/mountd/mountd.c	Mon Oct 15 00:17:16 2012	(r241568)
@@ -246,6 +246,7 @@ static int	mallocd_svcport = 0;
 static int	*sock_fd;
 static int	sock_fdcnt;
 static int	sock_fdpos;
+static int	suspend_nfsd = 0;
 
 int opt_flags;
 static int have_v6 = 1;
@@ -311,7 +312,7 @@ main(int argc, char **argv)
 	else
 		close(s);
 
-	while ((c = getopt(argc, argv, "2deh:lnop:r")) != -1)
+	while ((c = getopt(argc, argv, "2deh:lnop:rS")) != -1)
 		switch (c) {
 		case '2':
 			force_v2 = 1;
@@ -363,6 +364,9 @@ main(int argc, char **argv)
 				out_of_mem();
 			}
 			break;
+		case 'S':
+			suspend_nfsd = 1;
+			break;
 		default:
 			usage();
 		};
@@ -921,7 +925,7 @@ usage(void)
 {
 	fprintf(stderr,
 		"usage: mountd [-2] [-d] [-e] [-l] [-n] [-p <port>] [-r] "
-		"[-h <bindip>] [export_file ...]\n");
+		"[-S] [-h <bindip>] [export_file ...]\n");
 	exit(1);
 }
 
@@ -1659,6 +1663,8 @@ get_exportlist(void)
 	int done;
 	struct nfsex_args eargs;
 
+	if (suspend_nfsd != 0)
+		(void)nfssvc(NFSSVC_SUSPENDNFSD, NULL);
 	v4root_dirpath[0] = '\0';
 	bzero(&export, sizeof(export));
 	export.ex_flags = MNT_DELEXPORT;
@@ -1787,6 +1793,9 @@ get_exportlist(void)
 	 */
 	if (run_v4server > 0 && has_publicfh == 0)
 		(void) nfssvc(NFSSVC_NOPUBLICFH, NULL);
+
+	/* Resume the nfsd. If they weren't suspended, this is harmless. */
+	(void)nfssvc(NFSSVC_RESUMENFSD, NULL);
 }
 
 /*



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