summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2015-07-03 01:15:21 +0000
committerrmacklem <rmacklem@FreeBSD.org>2015-07-03 01:15:21 +0000
commit97c35a724e2ddf4cac77dc834d4621d626537caf (patch)
tree7c0943d6ff397ef91d5154b9d4a928a925d062fc /sys/fs
parent4fc5e01d2ed52f740fe1defd507102edd38157a7 (diff)
downloadFreeBSD-src-97c35a724e2ddf4cac77dc834d4621d626537caf.zip
FreeBSD-src-97c35a724e2ddf4cac77dc834d4621d626537caf.tar.gz
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. Reported by: alex.burlyga.ietf@gmail.com Tested by: alex.burlyga.ietf@gmail.com MFC after: 2 weeks
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/nfsclient/nfs_clrpcops.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index 55eb983..4528855 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -46,6 +46,13 @@ __FBSDID("$FreeBSD$");
#include "opt_inet6.h"
#include <fs/nfs/nfsport.h>
+#include <sys/sysctl.h>
+
+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
@@ -2530,8 +2537,12 @@ nfsrpc_symlink(vnode_t dvp, char *name, int namelen, char *target,
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);
}
@@ -2550,10 +2561,12 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap,
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);
@@ -2605,9 +2618,13 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap,
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);
}
OpenPOWER on IntegriCloud