change n_mtime from time_t to timespec in order to improve

cache consistency.
(1 second granularity is too loose these days.)
This commit is contained in:
yamt 2003-09-26 11:51:53 +00:00
parent 1d558954a5
commit c2025ab0ea
6 changed files with 32 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs.h,v 1.41 2003/08/16 18:08:27 yamt Exp $ */
/* $NetBSD: nfs.h,v 1.42 2003/09/26 11:51:53 yamt Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
@ -155,9 +155,9 @@ extern int nfs_niothreads; /* Number of async_daemons desired */
*/
#define NFS_ATTRTIMEO(np) \
((((np)->n_flag & NMODIFIED) || \
(time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
(time.tv_sec - (np)->n_mtime) / 10))
(time.tv_sec - (np)->n_mtime.tv_sec) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
((time.tv_sec - (np)->n_mtime.tv_sec) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
(time.tv_sec - (np)->n_mtime.tv_sec) / 10))
/*
* Expected allocation sizes for major data structures. If the actual size

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_bio.c,v 1.109 2003/09/17 09:11:12 yamt Exp $ */
/* $NetBSD: nfs_bio.c,v 1.110 2003/09/26 11:51:53 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.109 2003/09/17 09:11:12 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.110 2003/09/26 11:51:53 yamt Exp $");
#include "opt_nfs.h"
#include "opt_ddb.h"
@ -146,12 +146,12 @@ nfs_bioread(vp, uio, ioflag, cred, cflag)
error = VOP_GETATTR(vp, &vattr, cred, p);
if (error)
return (error);
np->n_mtime = vattr.va_mtime.tv_sec;
np->n_mtime = vattr.va_mtime;
} else {
error = VOP_GETATTR(vp, &vattr, cred, p);
if (error)
return (error);
if (np->n_mtime != vattr.va_mtime.tv_sec) {
if (timespeccmp(&np->n_mtime, &vattr.va_mtime, !=)) {
if (vp->v_type == VDIR) {
nfs_invaldircache(vp, 0);
np->n_direofoffset = 0;
@ -159,7 +159,7 @@ nfs_bioread(vp, uio, ioflag, cred, cflag)
error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
if (error)
return (error);
np->n_mtime = vattr.va_mtime.tv_sec;
np->n_mtime = vattr.va_mtime;
}
}
}
@ -925,7 +925,7 @@ nfs_doio_read(bp, uiop)
NQNFS_CKINVALID(vp, np, ND_READ) &&
np->n_lrev != np->n_brev) ||
(!(nmp->nm_flag & NFSMNT_NQNFS) &&
np->n_mtime != np->n_vattr->va_mtime.tv_sec))) {
timespeccmp(&np->n_mtime, &np->n_vattr->va_mtime, !=)))) {
uprintf("Process killed due to "
"text file modification\n");
psignal(uiop->uio_procp, SIGKILL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_subs.c,v 1.127 2003/08/07 16:33:53 agc Exp $ */
/* $NetBSD: nfs_subs.c,v 1.128 2003/09/26 11:51:53 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.127 2003/08/07 16:33:53 agc Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.128 2003/09/26 11:51:53 yamt Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -1644,7 +1644,7 @@ nfs_loadattrcache(vpp, fp, vaper, flags)
*vpp = vp = nvp;
}
}
np->n_mtime = mtime.tv_sec;
np->n_mtime = mtime;
}
uid = fxdr_unsigned(uid_t, fp->fa_uid);
gid = fxdr_unsigned(gid_t, fp->fa_gid);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vnops.c,v 1.179 2003/09/25 23:10:58 enami Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.180 2003/09/26 11:51:53 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.179 2003/09/25 23:10:58 enami Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.180 2003/09/26 11:51:53 yamt Exp $");
#include "opt_nfs.h"
#include "opt_uvmhist.h"
@ -498,12 +498,12 @@ nfs_open(v)
error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
if (error)
return (error);
np->n_mtime = vattr.va_mtime.tv_sec;
np->n_mtime = vattr.va_mtime;
} else {
error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
if (error)
return (error);
if (np->n_mtime != vattr.va_mtime.tv_sec) {
if (timespeccmp(&np->n_mtime, &vattr.va_mtime, !=)) {
if (vp->v_type == VDIR) {
nfs_invaldircache(vp, 0);
np->n_direofoffset = 0;
@ -511,7 +511,7 @@ nfs_open(v)
if ((error = nfs_vinvalbuf(vp, V_SAVE,
ap->a_cred, ap->a_p, 1)) == EINTR)
return (error);
np->n_mtime = vattr.va_mtime.tv_sec;
np->n_mtime = vattr.va_mtime;
}
}
}
@ -1405,8 +1405,7 @@ retry:
} else
nfsm_loadattr(vp, (struct vattr *)0, NAC_NOTRUNC);
if (wccflag)
VTONFS(vp)->n_mtime =
VTONFS(vp)->n_vattr->va_mtime.tv_sec;
VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr->va_mtime;
m_freem(mrep);
if (error)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsm_subs.h,v 1.31 2003/08/07 16:33:56 agc Exp $ */
/* $NetBSD: nfsm_subs.h,v 1.32 2003/09/26 11:51:53 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -217,9 +217,12 @@
nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
if (*tl == nfs_true) { \
nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
if (f) \
ttretf = (VTONFS(v)->n_mtime == \
fxdr_unsigned(u_int32_t, *(tl + 2))); \
if (f) { \
struct timespec mtime; \
fxdr_nfsv3time(tl + 2, &mtime); \
ttretf = timespeccmp(&VTONFS(v)->n_mtime, \
&mtime, ==); \
} \
} \
nfsm_postop_attr((v), ttattrf, (flags)); \
if (f) { \

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsnode.h,v 1.43 2003/09/17 09:10:02 yamt Exp $ */
/* $NetBSD: nfsnode.h,v 1.44 2003/09/26 11:51:53 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -119,7 +119,7 @@ struct nfsnode {
struct lockf *n_lockf; /* Locking record of file */
unsigned *n_dirgens; /* 32<->64bit xlate gen. no. */
time_t n_attrstamp; /* Attr. cache timestamp */
time_t n_mtime; /* Prev modify time. */
struct timespec n_mtime; /* Prev modify time. */
time_t n_ctime; /* Prev create time. */
struct timespec n_nctime; /* Last neg cache entry (dir) */
time_t n_expiry; /* Lease expiry time */