eliminate v_id.

This commit is contained in:
yamt 2003-07-30 12:10:57 +00:00
parent b0cdf0a26d
commit cc104d0635
6 changed files with 27 additions and 62 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_cache.c,v 1.46 2003/07/30 12:09:47 yamt Exp $ */
/* $NetBSD: vfs_cache.c,v 1.47 2003/07/30 12:10:57 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.46 2003/07/30 12:09:47 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.47 2003/07/30 12:10:57 yamt Exp $");
#include "opt_ddb.h"
#include "opt_revcache.h"
@ -79,11 +79,11 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.46 2003/07/30 12:09:47 yamt Exp $");
LIST_HEAD(nchashhead, namecache) *nchashtbl;
u_long nchash; /* size of hash table - 1 */
long numcache; /* number of cache entries allocated */
#define NCHASH(cnp, dvp) (((cnp)->cn_hash ^ (dvp)->v_id) & nchash)
#define NCHASH(cnp, dvp) ((cnp)->cn_hash & nchash)
LIST_HEAD(ncvhashhead, namecache) *ncvhashtbl;
u_long ncvhash; /* size of hash table - 1 */
#define NCVHASH(vp) ((vp)->v_id & ncvhash)
#define NCVHASH(vp) (((int)(vp) >> 3) & ncvhash)
TAILQ_HEAD(, namecache) nclruhead; /* LRU chain */
struct nchstats nchstats; /* cache effectiveness statistics */
@ -158,7 +158,6 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
struct namecache *ncp;
struct nchashhead *ncpp;
struct vnode *vp;
u_long vpid;
int error;
if (!doingcache) {
@ -176,7 +175,6 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
ncpp = &nchashtbl[NCHASH(cnp, dvp)];
LIST_FOREACH(ncp, ncpp, nc_hash) {
if (ncp->nc_dvp == dvp &&
ncp->nc_dvpid == dvp->v_id &&
ncp->nc_nlen == cnp->cn_namelen &&
!memcmp(ncp->nc_name, cnp->cn_nameptr, (u_int)ncp->nc_nlen))
break;
@ -210,13 +208,9 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
nchstats.ncs_badhits++;
goto remove;
}
} else if (ncp->nc_vpid != ncp->nc_vp->v_id) {
nchstats.ncs_falsehits++;
goto remove;
}
vp = ncp->nc_vp;
vpid = vp->v_id;
/* Release the name cache mutex while we acquire vnode locks */
simple_unlock(&namecache_slock);
@ -254,7 +248,7 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
* Check that the lock succeeded, and that the capability number did
* not change while we were waiting for the lock.
*/
if (error || vpid != vp->v_id) {
if (error) {
/* XXXSMP - updating stats without lock; do we care? */
if (!error) {
vput(vp);
@ -340,10 +334,8 @@ cache_revlookup(struct vnode *vp, struct vnode **dvpp, char **bpp, char *bufp)
simple_lock(&namecache_slock);
LIST_FOREACH(ncp, nvcpp, nc_vhash) {
if (ncp->nc_vp == vp &&
ncp->nc_vpid == vp->v_id &&
(dvp = ncp->nc_dvp) != NULL &&
dvp != vp && /* avoid pesky . entries.. */
dvp->v_id == ncp->nc_dvpid) {
dvp != vp) { /* avoid pesky . entries.. */
#ifdef DIAGNOSTIC
if (ncp->nc_nlen == 1 &&
@ -416,9 +408,7 @@ cache_enter(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
}
/* Grab the vnode we just found. */
ncp->nc_vp = vp;
if (vp)
ncp->nc_vpid = vp->v_id;
else {
if (vp == NULL) {
/*
* For negative hits, save the ISWHITEOUT flag so we can
* restore it later when the cache entry is used again.
@ -430,7 +420,6 @@ cache_enter(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
LIST_INSERT_HEAD(&dvp->v_dnclist, ncp, nc_dvlist);
if (vp)
LIST_INSERT_HEAD(&vp->v_nclist, ncp, nc_vlist);
ncp->nc_dvpid = dvp->v_id;
ncp->nc_nlen = cnp->cn_namelen;
memcpy(ncp->nc_name, cnp->cn_nameptr, (unsigned)ncp->nc_nlen);
TAILQ_INSERT_TAIL(&nclruhead, ncp, nc_lru);
@ -529,8 +518,6 @@ void
cache_purge(struct vnode *vp)
{
struct namecache *ncp, *ncnext;
struct nchashhead *ncpp;
static u_long nextvnodeid;
simple_lock(&namecache_slock);
for (ncp = LIST_FIRST(&vp->v_nclist); ncp != NULL; ncp = ncnext) {
@ -543,17 +530,6 @@ cache_purge(struct vnode *vp)
cache_remove(ncp);
cache_free(ncp);
}
vp->v_id = ++nextvnodeid;
if (nextvnodeid != 0)
goto out;
for (ncpp = &nchashtbl[nchash]; ncpp >= nchashtbl; ncpp--) {
LIST_FOREACH(ncp, ncpp, nc_hash) {
ncp->nc_vpid = 0;
ncp->nc_dvpid = 0;
}
}
vp->v_id = ++nextvnodeid;
out:
simple_unlock(&namecache_slock);
}
@ -587,7 +563,7 @@ namecache_print(struct vnode *vp, void (*pr)(const char *, ...))
struct namecache *ncp;
TAILQ_FOREACH(ncp, &nclruhead, nc_lru) {
if (ncp->nc_vp == vp && ncp->nc_vpid == vp->v_id) {
if (ncp->nc_vp == vp) {
(*pr)("name %.*s\n", ncp->nc_nlen, ncp->nc_name);
dvp = ncp->nc_dvp;
}
@ -598,7 +574,7 @@ namecache_print(struct vnode *vp, void (*pr)(const char *, ...))
}
vp = dvp;
TAILQ_FOREACH(ncp, &nclruhead, nc_lru) {
if (ncp->nc_vp == vp && ncp->nc_vpid == vp->v_id) {
if (ncp->nc_vp == vp) {
(*pr)("parent %.*s\n", ncp->nc_nlen, ncp->nc_name);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_getcwd.c,v 1.20 2003/06/29 22:31:33 fvdl Exp $ */
/* $NetBSD: vfs_getcwd.c,v 1.21 2003/07/30 12:10:57 yamt Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.20 2003/06/29 22:31:33 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.21 2003/07/30 12:10:57 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -309,7 +309,6 @@ getcwd_getcache(lvpp, uvpp, bpp, bufp)
{
struct vnode *lvp, *uvp = NULL;
int error;
int vpid;
lvp = *lvpp;
@ -327,7 +326,6 @@ getcwd_getcache(lvpp, uvpp, bpp, bufp)
return error;
}
uvp = *uvpp;
vpid = uvp->v_id;
/*
* Since we're going up, we have to release the current lock
@ -343,7 +341,7 @@ getcwd_getcache(lvpp, uvpp, bpp, bufp)
* Verify that vget succeeded, and check that vnode capability
* didn't change while we were waiting for the lock.
*/
if (error || (vpid != uvp->v_id)) {
if (error) {
/*
* Oops, we missed. If the vget failed, or the
* capability changed, try to get our lock back; if

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_subr.c,v 1.202 2003/07/30 12:09:47 yamt Exp $ */
/* $NetBSD: vfs_subr.c,v 1.203 2003/07/30 12:10:58 yamt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.202 2003/07/30 12:09:47 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.203 2003/07/30 12:10:58 yamt Exp $");
#include "opt_inet.h"
#include "opt_ddb.h"
@ -3048,9 +3048,9 @@ vfs_vnode_print(vp, full, pr)
vp->v_tag < sizeof(vnode_tags) / sizeof(vnode_tags[0])) ?
vnode_tags[vp->v_tag] : "UNKNOWN";
(*pr)("type %s(%d) tag %s(%d) id 0x%lx mount %p typedata %p\n",
(*pr)("type %s(%d) tag %s(%d) mount %p typedata %p\n",
vtype, vp->v_type, vtag, vp->v_tag,
vp->v_id, vp->v_mount, vp->v_mountedhere);
vp->v_mount, vp->v_mountedhere);
if (full) {
struct buf *bp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_nqlease.c,v 1.51 2003/06/29 22:32:15 fvdl Exp $ */
/* $NetBSD: nfs_nqlease.c,v 1.52 2003/07/30 12:10:58 yamt Exp $ */
/*
* Copyright (c) 1992, 1993
@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_nqlease.c,v 1.51 2003/06/29 22:32:15 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_nqlease.c,v 1.52 2003/07/30 12:10:58 yamt Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -1019,7 +1019,6 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, l)
struct nfsnode *np;
struct vnode *vp;
struct nfsreq myrep;
int vpid;
#endif
int error = 0, sleepreturn;
struct nfsuid *nuidp, *nnuidp;
@ -1096,11 +1095,9 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, l)
while (np != (void *)&nmp->nm_timerhead &&
(nmp->nm_iflag & NFSMNT_DISMINPROG) == 0) {
vp = NFSTOV(np);
vpid = vp->v_id;
if (np->n_expiry < time.tv_sec) {
if (vget(vp, LK_EXCLUSIVE) == 0) {
nmp->nm_inprog = vp;
if (vpid == vp->v_id) {
nmp->nm_inprog = vp;
CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer);
/* mark this off the list */
CIRCLEQ_NEXT(np, n_timer) = 0; /* XXX */
@ -1119,9 +1116,8 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, l)
np->n_flag &= ~NMODIFIED;
}
}
}
vput(vp);
nmp->nm_inprog = NULLVP;
vput(vp);
nmp->nm_inprog = NULLVP;
}
} else if ((np->n_expiry - NQ_RENEWAL) < time.tv_sec) {
if ((np->n_flag & (NQNFSWRITE | NQNFSNONCACHE))
@ -1129,8 +1125,7 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, l)
!LIST_EMPTY(&vp->v_dirtyblkhd) &&
vget(vp, LK_EXCLUSIVE) == 0) {
nmp->nm_inprog = vp;
if (vpid == vp->v_id &&
nqnfs_getlease(vp, ND_WRITE, cred, p)==0)
if (nqnfs_getlease(vp, ND_WRITE, cred, p)==0)
np->n_brev = np->n_lrev;
vput(vp);
nmp->nm_inprog = NULLVP;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vnode.h,v 1.114 2003/07/30 12:09:47 yamt Exp $ */
/* $NetBSD: vnode.h,v 1.115 2003/07/30 12:10:59 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -94,7 +94,6 @@ struct vnode {
int v_numoutput; /* number of pending writes */
long v_writecount; /* reference count of writers */
long v_holdcnt; /* page & buffer references */
u_long v_id; /* capability identifier */
struct mount *v_mount; /* ptr to vfs we are in */
int (**v_op) __P((void *)); /* vnode operations vector */
TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.17 2003/07/15 05:59:58 itojun Exp $ */
/* $NetBSD: pmap.c,v 1.18 2003/07/30 12:11:43 yamt Exp $ */
/*
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pmap.c,v 1.17 2003/07/15 05:59:58 itojun Exp $");
__RCSID("$NetBSD: pmap.c,v 1.18 2003/07/30 12:11:43 yamt Exp $");
#endif
#include <string.h>
@ -790,28 +790,25 @@ search_cache(kvm_t *kd, struct kbit *vp, char **name, char *buf, size_t blen)
char *o, *e;
struct cache_entry *ce;
struct kbit svp;
u_long cid;
if (nchashtbl == NULL)
load_name_cache(kd);
P(&svp) = P(vp);
S(&svp) = sizeof(struct vnode);
cid = D(vp, vnode)->v_id;
e = &buf[blen - 1];
o = e;
do {
LIST_FOREACH(ce, &lcache, ce_next)
if (ce->ce_vp == P(&svp) && ce->ce_cid == cid)
if (ce->ce_vp == P(&svp))
break;
if (ce && ce->ce_vp == P(&svp) && ce->ce_cid == cid) {
if (ce && ce->ce_vp == P(&svp)) {
if (o != e)
*(--o) = '/';
o -= ce->ce_nlen;
memcpy(o, ce->ce_name, (unsigned)ce->ce_nlen);
P(&svp) = ce->ce_pvp;
cid = ce->ce_pcid;
}
else
break;