From owner-svn-src-all@FreeBSD.ORG Fri Feb 1 00:32:02 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2B106BD0; Fri, 1 Feb 2013 00:32:02 +0000 (UTC) (envelope-from delphij@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 039D6DBB; Fri, 1 Feb 2013 00:32:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r110W1xR090382; Fri, 1 Feb 2013 00:32:01 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r110W1ZY090381; Fri, 1 Feb 2013 00:32:01 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201302010032.r110W1ZY090381@svn.freebsd.org> From: Xin LI Date: Fri, 1 Feb 2013 00:32:01 +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: r246187 - stable/9/sys/fs/nfsserver X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2013 00:32:02 -0000 Author: delphij Date: Fri Feb 1 00:32:01 2013 New Revision: 246187 URL: http://svnweb.freebsd.org/changeset/base/246187 Log: MFC r245613: Make it possible to force async at server side on new NFS server, similar to the old one's nfs.nfsrv.async. Please note that by enabling this option (default is disabled), the system could potentionally have silent data corruption if the server crashes before write is committed to non-volatile storage, as the client side have no way to tell if the data is already written. Submitted by: rmacklem Modified: stable/9/sys/fs/nfsserver/nfs_nfsdserv.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdserv.c Thu Jan 31 22:43:38 2013 (r246186) +++ stable/9/sys/fs/nfsserver/nfs_nfsdserv.c Fri Feb 1 00:32:01 2013 (r246187) @@ -55,6 +55,11 @@ extern int nfs_rootfhset; extern int nfsrv_enable_crossmntpt; #endif /* !APPLEKEXT */ +static int nfs_async = 0; +SYSCTL_DECL(_vfs_nfsd); +SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0, + "Tell client that writes were synced even though they were not"); + /* * This list defines the GSS mechanisms supported. * (Don't ask me how you get these strings from the RFC stuff like @@ -912,7 +917,13 @@ nfsrvd_write(struct nfsrv_descript *nd, goto out; NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(retlen); - if (stable == NFSWRITE_UNSTABLE) + /* + * If nfs_async is set, then pretend the write was FILESYNC. + * Warning: Doing this violates RFC1813 and runs a risk + * of data written by a client being lost when the server + * crashes/reboots. + */ + if (stable == NFSWRITE_UNSTABLE && nfs_async == 0) *tl++ = txdr_unsigned(stable); else *tl++ = txdr_unsigned(NFSWRITE_FILESYNC);