make NFS_ATTRTIMEO a function.
This commit is contained in:
parent
08f1734743
commit
79606bd6fa
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs.h,v 1.67 2007/06/02 03:32:51 yamt Exp $ */
|
||||
/* $NetBSD: nfs.h,v 1.68 2007/10/28 22:24:28 yamt Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1995
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -164,16 +164,6 @@ extern int nfs_niothreads; /* Number of async_daemons desired */
|
||||
#define IO_METASYNC 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the attribute timeout based on how recently the file has been modified.
|
||||
*/
|
||||
#define NFS_ATTRTIMEO(nmp, np) \
|
||||
((nmp->nm_flag & NFSMNT_NOAC) ? 0 : \
|
||||
((((np)->n_flag & NMODIFIED) || \
|
||||
(time_second - (np)->n_mtime.tv_sec) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
|
||||
((time_second - (np)->n_mtime.tv_sec) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
|
||||
(time_second - (np)->n_mtime.tv_sec) / 10)))
|
||||
|
||||
/*
|
||||
* Export arguments for local filesystem mount calls.
|
||||
* Keep in mind that changing this structure modifies nfssvc(2)'s ABI (see
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_bio.c,v 1.168 2007/10/10 20:42:31 ad Exp $ */
|
||||
/* $NetBSD: nfs_bio.c,v 1.169 2007/10/28 22:24:28 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.168 2007/10/10 20:42:31 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.169 2007/10/28 22:24:28 yamt Exp $");
|
||||
|
||||
#include "opt_nfs.h"
|
||||
#include "opt_ddb.h"
|
||||
@ -124,7 +124,7 @@ nfs_bioread(vp, uio, ioflag, cred, cflag)
|
||||
* Then force a getattr rpc to ensure that you have up to date
|
||||
* attributes.
|
||||
* NB: This implies that cache data can be read when up to
|
||||
* NFS_ATTRTIMEO seconds out of date. If you find that you need current
|
||||
* nfs_attrtimeo seconds out of date. If you find that you need current
|
||||
* attributes this could be forced by setting n_attrstamp to 0 before
|
||||
* the VOP_GETATTR() call.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_subs.c,v 1.191 2007/07/27 10:03:58 yamt Exp $ */
|
||||
/* $NetBSD: nfs_subs.c,v 1.192 2007/10/28 22:24:29 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -70,7 +70,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.191 2007/07/27 10:03:58 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.192 2007/10/28 22:24:29 yamt Exp $");
|
||||
|
||||
#include "fs_nfs.h"
|
||||
#include "opt_nfs.h"
|
||||
@ -1810,7 +1810,7 @@ nfs_getattrcache(vp, vaper)
|
||||
struct vattr *vap;
|
||||
|
||||
if (np->n_attrstamp == 0 ||
|
||||
(time_second - np->n_attrstamp) >= NFS_ATTRTIMEO(nmp, np)) {
|
||||
(time_second - np->n_attrstamp) >= nfs_attrtimeo(nmp, np)) {
|
||||
nfsstats.attrcache_misses++;
|
||||
return (ENOENT);
|
||||
}
|
||||
@ -2992,3 +2992,26 @@ nfsrv_copyfh(nfsrvfh_t *fh1, const nfsrvfh_t *fh2)
|
||||
memcpy(NFSRVFH_DATA(fh1), NFSRVFH_DATA(fh2), size);
|
||||
}
|
||||
#endif /* defined(NFSSERVER) */
|
||||
|
||||
#if defined(NFS)
|
||||
/*
|
||||
* Set the attribute timeout based on how recently the file has been modified.
|
||||
*/
|
||||
|
||||
time_t
|
||||
nfs_attrtimeo(struct nfsmount *nmp, struct nfsnode *np)
|
||||
{
|
||||
time_t timeo;
|
||||
|
||||
if ((nmp->nm_flag & NFSMNT_NOAC) != 0)
|
||||
return 0;
|
||||
|
||||
if (((np)->n_flag & NMODIFIED) != 0)
|
||||
return NFS_MINATTRTIMO;
|
||||
|
||||
timeo = (time_second - np->n_mtime.tv_sec) / 10;
|
||||
timeo = max(timeo, NFS_MINATTRTIMO);
|
||||
timeo = min(timeo, NFS_MAXATTRTIMO);
|
||||
return timeo;
|
||||
}
|
||||
#endif /* defined(NFS) */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_var.h,v 1.73 2007/10/21 08:23:19 yamt Exp $ */
|
||||
/* $NetBSD: nfs_var.h,v 1.74 2007/10/28 22:24:29 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
@ -255,6 +255,7 @@ int nfsrv_fhtovp(nfsrvfh_t *, int, struct vnode **, kauth_cred_t,
|
||||
struct nfssvc_sock *, struct mbuf *, int *, int, int);
|
||||
int nfs_ispublicfh __P((const nfsrvfh_t *));
|
||||
int netaddr_match(int, union nethostaddr *, struct mbuf *);
|
||||
time_t nfs_attrtimeo(struct nfsmount *, struct nfsnode *);
|
||||
|
||||
/* flags for nfs_loadattrcache and friends */
|
||||
#define NAC_NOTRUNC 1 /* don't truncate file size */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_vfsops.c,v 1.186 2007/10/10 20:42:31 ad Exp $ */
|
||||
/* $NetBSD: nfs_vfsops.c,v 1.187 2007/10/28 22:24:29 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1995
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.186 2007/10/10 20:42:31 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.187 2007/10/28 22:24:29 yamt Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -329,7 +329,7 @@ nfs_mountroot()
|
||||
* XXX time must be non-zero when we init the interface or else
|
||||
* the arp code will wedge. [Fixed now in if_ether.c]
|
||||
* However, the NFS attribute cache gives false "hits" when the
|
||||
* current time < NFS_ATTRTIMEO(nmp, np) so keep this in for now.
|
||||
* current time < nfs_attrtimeo(nmp, np) so keep this in for now.
|
||||
*/
|
||||
if (time_second < NFS_MAXATTRTIMO) {
|
||||
#ifdef __HAVE_TIMECOUNTER
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_vnops.c,v 1.256 2007/07/09 21:11:31 ad Exp $ */
|
||||
/* $NetBSD: nfs_vnops.c,v 1.257 2007/10/28 22:24:29 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.256 2007/07/09 21:11:31 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.257 2007/10/28 22:24:29 yamt Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_nfs.h"
|
||||
@ -331,7 +331,7 @@ nfs_access(v)
|
||||
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
|
||||
|
||||
cachevalid = (np->n_accstamp != -1 &&
|
||||
(time_uptime - np->n_accstamp) < NFS_ATTRTIMEO(nmp, np) &&
|
||||
(time_uptime - np->n_accstamp) < nfs_attrtimeo(nmp, np) &&
|
||||
np->n_accuid == kauth_cred_geteuid(ap->a_cred));
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user