diff options
| author | 2009-01-19 23:40:36 +0000 | |
|---|---|---|
| committer | 2009-01-19 23:40:36 +0000 | |
| commit | fdc7e2e58d1bb00cdcc1be13de80732ae071c84a (patch) | |
| tree | d03567a47e547f1d571441d09c37e6dee4003ce0 | |
| parent | updates for BKK and DMK; based on a diff from Robert Elz, submitted (diff) | |
| download | wireguard-openbsd-fdc7e2e58d1bb00cdcc1be13de80732ae071c84a.tar.xz wireguard-openbsd-fdc7e2e58d1bb00cdcc1be13de80732ae071c84a.zip | |
Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.
Lift the macro name from NetBSD.
prompted by and OK blambert@
| -rw-r--r-- | sys/nfs/nfs_bio.c | 12 | ||||
| -rw-r--r-- | sys/nfs/nfs_kq.c | 4 | ||||
| -rw-r--r-- | sys/nfs/nfs_vnops.c | 31 | ||||
| -rw-r--r-- | sys/nfs/nfsnode.h | 4 |
4 files changed, 25 insertions, 26 deletions
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index 18c7690e422..cd50fbcd023 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_bio.c,v 1.55 2008/08/09 10:14:02 thib Exp $ */ +/* $OpenBSD: nfs_bio.c,v 1.56 2009/01/19 23:40:36 thib Exp $ */ /* $NetBSD: nfs_bio.c,v 1.25.4.2 1996/07/08 20:47:04 jtc Exp $ */ /* @@ -106,13 +106,9 @@ nfs_bioread(vp, uio, ioflag, cred) * server, so flush all of the file's data out of the cache. * 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 - * attributes this could be forced by setting n_attrstamp to 0 before - * the VOP_GETATTR() call. */ if (np->n_flag & NMODIFIED) { - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); error = VOP_GETATTR(vp, &vattr, cred, p); if (error) return (error); @@ -305,13 +301,13 @@ nfs_write(v) (void)nfs_fsinfo(nmp, vp, cred, p); if (ioflag & (IO_APPEND | IO_SYNC)) { if (np->n_flag & NMODIFIED) { - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); error = nfs_vinvalbuf(vp, V_SAVE, cred, p); if (error) return (error); } if (ioflag & IO_APPEND) { - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); error = VOP_GETATTR(vp, &vattr, cred, p); if (error) return (error); diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c index 54562628d4e..09326898c77 100644 --- a/sys/nfs/nfs_kq.c +++ b/sys/nfs/nfs_kq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_kq.c,v 1.14 2008/09/11 16:06:01 thib Exp $ */ +/* $OpenBSD: nfs_kq.c,v 1.15 2009/01/19 23:40:36 thib Exp $ */ /* $NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $ */ /*- @@ -126,7 +126,7 @@ nfs_kqpoll(void *arg) error = VOP_GETATTR(ke->vp, &attr, p->p_ucred, p); if (error == ESTALE) { - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); VN_KNOTE(ke->vp, NOTE_DELETE); goto next; } diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index ecd2b5c3a99..d3edf04eb96 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.107 2009/01/18 15:42:31 bluhm Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.108 2009/01/19 23:40:36 thib Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -398,7 +398,7 @@ nfs_open(v) if (error == EINTR) return (error); uvm_vnp_uncache(vp); - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); if (vp->v_type == VDIR) np->n_direofoffset = 0; error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); @@ -419,7 +419,8 @@ nfs_open(v) np->n_mtime = vattr.va_mtime.tv_sec; } } - np->n_attrstamp = 0; /* For Open/Close consistency */ + /* For open/close consistency. */ + NFS_INVALIDATE_ATTRCACHE(np); return (0); } @@ -466,7 +467,7 @@ nfs_close(v) np->n_flag &= ~NMODIFIED; } else error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p); - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); } if (np->n_flag & NWRITEERR) { np->n_flag &= ~NWRITEERR; @@ -1224,7 +1225,7 @@ nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); vrele(dvp); return (error); } @@ -1346,7 +1347,7 @@ nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); VN_KNOTE(ap->a_dvp, NOTE_WRITE); vrele(dvp); return (error); @@ -1414,7 +1415,7 @@ nfs_remove(v) } else if (!np->n_sillyrename) error = nfs_sillyrename(dvp, vp, cnp); pool_put(&namei_pool, cnp->cn_pnbuf); - np->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(np); vrele(dvp); vrele(vp); @@ -1466,7 +1467,7 @@ nfs_removerpc(dvp, name, namelen, cred, proc) nfsmout: VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); return (error); } @@ -1589,9 +1590,9 @@ nfsmout: VTONFS(fdvp)->n_flag |= NMODIFIED; VTONFS(tdvp)->n_flag |= NMODIFIED; if (!fwccflag) - VTONFS(fdvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(fdvp)); if (!twccflag) - VTONFS(tdvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(tdvp)); return (error); } @@ -1646,9 +1647,9 @@ nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!attrflag) - VTONFS(vp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(vp)); if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); VN_KNOTE(vp, NOTE_LINK); VN_KNOTE(dvp, NOTE_WRITE); @@ -1707,7 +1708,7 @@ nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); VN_KNOTE(dvp, NOTE_WRITE); vrele(dvp); return (error); @@ -1762,7 +1763,7 @@ nfs_mkdir(v) nfsmout: VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); if (error == 0 && newvp == NULL) { error = nfs_lookitup(dvp, cnp->cn_nameptr, len, cnp->cn_cred, @@ -1824,7 +1825,7 @@ nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; + NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); VN_KNOTE(dvp, NOTE_WRITE|NOTE_LINK); VN_KNOTE(vp, NOTE_DELETE); diff --git a/sys/nfs/nfsnode.h b/sys/nfs/nfsnode.h index 61c58b9cea9..53a3ce4ce98 100644 --- a/sys/nfs/nfsnode.h +++ b/sys/nfs/nfsnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsnode.h,v 1.31 2008/06/14 19:33:58 beck Exp $ */ +/* $OpenBSD: nfsnode.h,v 1.32 2009/01/19 23:40:36 thib Exp $ */ /* $NetBSD: nfsnode.h,v 1.16 1996/02/18 11:54:04 fvdl Exp $ */ /* @@ -129,6 +129,8 @@ struct nfsnode { #define NUPD 0x0200 /* Special file updated */ #define NCHG 0x0400 /* Special file times changed */ +#define NFS_INVALIDATE_ATTRCACHE(np) ((np)->n_attrstamp = 0) + /* * Convert between nfsnode pointers and vnode pointers */ |
