summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_vfsops.c
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2010-01-21 20:57:25 +0000
committerrmacklem <rmacklem@FreeBSD.org>2010-01-21 20:57:25 +0000
commit83fed061c4fe4086f0414be4bd83235282f469cb (patch)
treed2f3e7a905d8ed87e8e1eb783fdf9304aee04c83 /sys/nfsclient/nfs_vfsops.c
parentef4afc1830021f715196eb1daf782191b08e6549 (diff)
downloadFreeBSD-src-83fed061c4fe4086f0414be4bd83235282f469cb.zip
FreeBSD-src-83fed061c4fe4086f0414be4bd83235282f469cb.tar.gz
Add a timeout for the negative name cache entries in the NFS client.
This avoids a bogus negative name cache entry from persisting forever when another client creates an entry with the same name within the same NFS server time of day clock tick. The mount option negnametimeo can be used to override the default timeout interval on a per-mount-point basis. Setting negnametimeo to 0 disables negative name caching for the mount point. I also fixed one obvious typo where args.timeo should be args.maxgrouplist. Submitted by: jhb (earlier version) Reviewed by: jhb MFC after: 2 weeks
Diffstat (limited to 'sys/nfsclient/nfs_vfsops.c')
-rw-r--r--sys/nfsclient/nfs_vfsops.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index 2346d41..72ca2ce 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -114,7 +114,7 @@ static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp,
struct nfs_args *argp, const char *hostname);
static int mountnfs(struct nfs_args *, struct mount *,
struct sockaddr *, char *, struct vnode **,
- struct ucred *cred);
+ struct ucred *cred, int);
static vfs_mount_t nfs_mount;
static vfs_cmount_t nfs_cmount;
static vfs_unmount_t nfs_unmount;
@@ -551,7 +551,7 @@ nfs_mountdiskless(char *path,
nam = sodupsockaddr((struct sockaddr *)sin, M_WAITOK);
if ((error = mountnfs(args, mp, nam, path, vpp,
- td->td_ucred)) != 0) {
+ td->td_ucred, NFS_DEFAULT_NEGNAMETIMEO)) != 0) {
printf("nfs_mountroot: mount %s on /: %d\n", path, error);
return (error);
}
@@ -778,7 +778,7 @@ static const char *nfs_opts[] = { "from", "nfs_args",
"readdirsize", "soft", "hard", "mntudp", "tcp", "udp", "wsize", "rsize",
"retrans", "acregmin", "acregmax", "acdirmin", "acdirmax",
"deadthresh", "hostname", "timeout", "addr", "fh", "nfsv3", "sec",
- "maxgroups", "principal",
+ "maxgroups", "principal", "negnametimeo",
NULL };
/*
@@ -827,6 +827,7 @@ nfs_mount(struct mount *mp)
size_t len;
u_char nfh[NFSX_V3FHMAX];
char *opt;
+ int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO;
has_nfs_args_opt = 0;
has_addr_opt = 0;
@@ -1029,7 +1030,7 @@ nfs_mount(struct mount *mp)
}
if (vfs_getopt(mp->mnt_optnew, "maxgroups", (void **)&opt, NULL) == 0) {
ret = sscanf(opt, "%d", &args.maxgrouplist);
- if (ret != 1 || args.timeo <= 0) {
+ if (ret != 1 || args.maxgrouplist <= 0) {
vfs_mount_error(mp, "illegal maxgroups: %s",
opt);
error = EINVAL;
@@ -1037,6 +1038,16 @@ nfs_mount(struct mount *mp)
}
args.flags |= NFSMNT_MAXGRPS;
}
+ if (vfs_getopt(mp->mnt_optnew, "negnametimeo", (void **)&opt, NULL)
+ == 0) {
+ ret = sscanf(opt, "%d", &negnametimeo);
+ if (ret != 1 || negnametimeo < 0) {
+ vfs_mount_error(mp, "illegal negnametimeo: %s",
+ opt);
+ error = EINVAL;
+ goto out;
+ }
+ }
if (vfs_getopt(mp->mnt_optnew, "addr", (void **)&args.addr,
&args.addrlen) == 0) {
has_addr_opt = 1;
@@ -1125,7 +1136,7 @@ nfs_mount(struct mount *mp)
}
}
error = mountnfs(&args, mp, nam, args.hostname, &vp,
- curthread->td_ucred);
+ curthread->td_ucred, negnametimeo);
out:
if (!error) {
MNT_ILOCK(mp);
@@ -1167,7 +1178,7 @@ nfs_cmount(struct mntarg *ma, void *data, int flags)
*/
static int
mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
- char *hst, struct vnode **vpp, struct ucred *cred)
+ char *hst, struct vnode **vpp, struct ucred *cred, int negnametimeo)
{
struct nfsmount *nmp;
struct nfsnode *np;
@@ -1217,6 +1228,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
nmp->nm_numgrps = NFS_MAXGRPS;
nmp->nm_readahead = NFS_DEFRAHEAD;
nmp->nm_deadthresh = NFS_MAXDEADTHRESH;
+ nmp->nm_negnametimeo = negnametimeo;
nmp->nm_tprintf_delay = nfs_tprintf_delay;
if (nmp->nm_tprintf_delay < 0)
nmp->nm_tprintf_delay = 0;
OpenPOWER on IntegriCloud