From owner-svn-src-all@freebsd.org Mon Jul 27 00:28:52 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2EA59AA4E2; Mon, 27 Jul 2015 00:28:52 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 886C4C24; Mon, 27 Jul 2015 00:28:52 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6R0Sqqu052540; Mon, 27 Jul 2015 00:28:52 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6R0Sq6D052539; Mon, 27 Jul 2015 00:28:52 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201507270028.t6R0Sq6D052539@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Mon, 27 Jul 2015 00:28:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r285904 - stable/10/sys/fs/nfsclient X-SVN-Group: stable-10 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.20 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: Mon, 27 Jul 2015 00:28:52 -0000 Author: rmacklem Date: Mon Jul 27 00:28:51 2015 New Revision: 285904 URL: https://svnweb.freebsd.org/changeset/base/285904 Log: MFC: r285066 Alex Burlyga reported a POLA violation for the new NFS client as compared to the old NFS client via email to the freebsd-fs@ mailing list. For the new client, when multiple clients attempted to create a symbolic link concurrently, more that one client would report success instead of EEXIST. This was caused by code in the new client that mapped EEXIST to OK assuming it was caused by a retried RPC request. Since the old client did not do this, the patch defaults to the old behaviour and permits the new behaviour to be enabled via a sysctl. Modified: stable/10/sys/fs/nfsclient/nfs_clrpcops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- stable/10/sys/fs/nfsclient/nfs_clrpcops.c Sun Jul 26 21:37:31 2015 (r285903) +++ stable/10/sys/fs/nfsclient/nfs_clrpcops.c Mon Jul 27 00:28:51 2015 (r285904) @@ -46,6 +46,13 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include +#include + +SYSCTL_DECL(_vfs_nfs); + +static int nfsignore_eexist = 0; +SYSCTL_INT(_vfs_nfs, OID_AUTO, ignore_eexist, CTLFLAG_RW, + &nfsignore_eexist, 0, "NFS ignore EEXIST replies for mkdir/symlink"); /* * Global variables @@ -2528,8 +2535,12 @@ nfsrpc_symlink(vnode_t dvp, char *name, mbuf_freem(nd->nd_mrep); /* * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry. + * Only do this if vfs.nfs.ignore_eexist is set. + * Never do this for NFSv4.1 or later minor versions, since sessions + * should guarantee "exactly once" RPC semantics. */ - if (error == EEXIST) + if (error == EEXIST && nfsignore_eexist != 0 && (!NFSHASNFSV4(nmp) || + nmp->nm_minorvers == 0)) error = 0; return (error); } @@ -2548,10 +2559,12 @@ nfsrpc_mkdir(vnode_t dvp, char *name, in nfsattrbit_t attrbits; int error = 0; struct nfsfh *fhp; + struct nfsmount *nmp; *nfhpp = NULL; *attrflagp = 0; *dattrflagp = 0; + nmp = VFSTONFS(vnode_mount(dvp)); fhp = VTONFS(dvp)->n_fhp; if (namelen > NFS_MAXNAMLEN) return (ENAMETOOLONG); @@ -2603,9 +2616,13 @@ nfsrpc_mkdir(vnode_t dvp, char *name, in nfsmout: mbuf_freem(nd->nd_mrep); /* - * Kludge: Map EEXIST => 0 assuming that you have a reply to a retry. + * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry. + * Only do this if vfs.nfs.ignore_eexist is set. + * Never do this for NFSv4.1 or later minor versions, since sessions + * should guarantee "exactly once" RPC semantics. */ - if (error == EEXIST) + if (error == EEXIST && nfsignore_eexist != 0 && (!NFSHASNFSV4(nmp) || + nmp->nm_minorvers == 0)) error = 0; return (error); }