From owner-svn-src-stable@FreeBSD.ORG Sat Dec 1 01:12:00 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 94E10B79; Sat, 1 Dec 2012 01:12:00 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5DA0B8FC0C; Sat, 1 Dec 2012 01:12:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qB11C0Q7094521; Sat, 1 Dec 2012 01:12:00 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qB11C0cM094520; Sat, 1 Dec 2012 01:12:00 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201212010112.qB11C0cM094520@svn.freebsd.org> From: Rick Macklem Date: Sat, 1 Dec 2012 01:12:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r243739 - stable/9/usr.sbin/mountd X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Dec 2012 01:12:00 -0000 Author: rmacklem Date: Sat Dec 1 01:11:59 2012 New Revision: 243739 URL: http://svnweb.freebsd.org/changeset/base/243739 Log: MFC: r241568 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. Modified: stable/9/usr.sbin/mountd/mountd.c Directory Properties: stable/9/usr.sbin/mountd/ (props changed) Modified: stable/9/usr.sbin/mountd/mountd.c ============================================================================== --- stable/9/usr.sbin/mountd/mountd.c Sat Dec 1 01:07:51 2012 (r243738) +++ stable/9/usr.sbin/mountd/mountd.c Sat Dec 1 01:11:59 2012 (r243739) @@ -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 ] [-r] " - "[-h ] [export_file ...]\n"); + "[-S] [-h ] [export_file ...]\n"); exit(1); } @@ -1660,6 +1664,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; @@ -1790,6 +1796,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); } /*