Convert hash tables.
This commit is contained in:
parent
45afd5bdba
commit
537ac5465f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fdesc.h,v 1.5 1994/06/29 06:34:14 cgd Exp $ */
|
||||
/* $NetBSD: fdesc.h,v 1.6 1994/08/19 11:25:29 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -62,8 +62,7 @@ typedef enum {
|
||||
} fdntype;
|
||||
|
||||
struct fdescnode {
|
||||
struct fdescnode *fd_forw; /* Hash chain */
|
||||
struct fdescnode *fd_back;
|
||||
LIST_ENTRY(fdescnode) fd_hash; /* Hash list */
|
||||
struct vnode *fd_vnode; /* Back ptr to vnode */
|
||||
fdntype fd_type; /* Type of this node */
|
||||
unsigned fd_fd; /* Fd to be dup'ed */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fdesc_vnops.c,v 1.16 1994/07/14 20:58:28 mycroft Exp $ */
|
||||
/* $NetBSD: fdesc_vnops.c,v 1.17 1994/08/19 11:25:31 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -74,40 +74,20 @@ FD_STDIN, FD_STDOUT, FD_STDERR must be a sequence n, n+1, n+2
|
||||
#endif
|
||||
|
||||
#define NFDCACHE 4
|
||||
#define FD_NHASH(ix) ((ix) & (NFDCACHE-1))
|
||||
|
||||
/*
|
||||
* Cache head
|
||||
*/
|
||||
struct fdcache {
|
||||
struct fdescnode *fc_forw;
|
||||
struct fdescnode *fc_back;
|
||||
};
|
||||
|
||||
static struct fdcache fdcache[NFDCACHE];
|
||||
#define FD_NHASH(ix) \
|
||||
(&fdhashtbl[(ix) & fdhash])
|
||||
LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl;
|
||||
u_long fdhash;
|
||||
|
||||
/*
|
||||
* Initialise cache headers
|
||||
*/
|
||||
fdesc_init()
|
||||
{
|
||||
struct fdcache *fc;
|
||||
|
||||
devctty = makedev(nchrdev, 0);
|
||||
|
||||
for (fc = fdcache; fc < fdcache + NFDCACHE; fc++)
|
||||
fc->fc_forw = fc->fc_back = (struct fdescnode *) fc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute hash list for given target vnode
|
||||
*/
|
||||
static struct fdcache *
|
||||
fdesc_hash(ix)
|
||||
int ix;
|
||||
{
|
||||
|
||||
return (&fdcache[FD_NHASH(ix)]);
|
||||
fdhashtbl = hashinit(NFDCACHE, M_CACHE, &fdhash);
|
||||
}
|
||||
|
||||
int
|
||||
@ -117,13 +97,13 @@ fdesc_allocvp(ftype, ix, mp, vpp)
|
||||
struct mount *mp;
|
||||
struct vnode **vpp;
|
||||
{
|
||||
struct fdcache *fc;
|
||||
struct fdhashhead *fc;
|
||||
struct fdescnode *fd;
|
||||
int error = 0;
|
||||
|
||||
fc = FD_NHASH(ix);
|
||||
loop:
|
||||
fc = fdesc_hash(ix);
|
||||
for (fd = fc->fc_forw; fd != (struct fdescnode *) fc; fd = fd->fd_forw) {
|
||||
for (fd = fc->lh_first; fd != 0; fd = fd->fd_hash.le_next) {
|
||||
if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) {
|
||||
if (vget(fd->fd_vnode, 0))
|
||||
goto loop;
|
||||
@ -153,8 +133,7 @@ loop:
|
||||
fd->fd_fd = -1;
|
||||
fd->fd_link = 0;
|
||||
fd->fd_ix = ix;
|
||||
fc = fdesc_hash(ix);
|
||||
insque(fd, fc);
|
||||
LIST_INSERT_HEAD(fc, fd, fd_hash);
|
||||
|
||||
out:;
|
||||
fdcache_lock &= ~FDL_LOCKED;
|
||||
@ -790,8 +769,9 @@ fdesc_reclaim(ap)
|
||||
} */ *ap;
|
||||
{
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct fdescnode *fd = VTOFDESC(vp);
|
||||
|
||||
remque(VTOFDESC(vp));
|
||||
LIST_REMOVE(fd, fd_hash);
|
||||
FREE(vp->v_data, M_TEMP);
|
||||
vp->v_data = 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: null.h,v 1.2 1994/06/29 06:34:31 cgd Exp $ */
|
||||
/* $NetBSD: null.h,v 1.3 1994/08/19 11:25:33 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -53,8 +53,7 @@ struct null_mount {
|
||||
* A cache of vnode references
|
||||
*/
|
||||
struct null_node {
|
||||
struct null_node *null_forw; /* Hash chain */
|
||||
struct null_node *null_back;
|
||||
LIST_ENTRY(null_node) null_hash; /* Hash list */
|
||||
struct vnode *null_lowervp; /* VREFed once */
|
||||
struct vnode *null_vnode; /* Back pointer */
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: null_subr.c,v 1.2 1994/06/29 06:34:32 cgd Exp $ */
|
||||
/* $NetBSD: null_subr.c,v 1.3 1994/08/19 11:25:35 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -51,7 +51,6 @@
|
||||
|
||||
#define LOG2_SIZEVNODE 7 /* log2(sizeof struct vnode) */
|
||||
#define NNULLNODECACHE 16
|
||||
#define NULL_NHASH(vp) ((((u_long)vp)>>LOG2_SIZEVNODE) & (NNULLNODECACHE-1))
|
||||
|
||||
/*
|
||||
* Null layer cache:
|
||||
@ -61,39 +60,21 @@
|
||||
* alias is removed the lower vnode is vrele'd.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Cache head
|
||||
*/
|
||||
struct null_node_cache {
|
||||
struct null_node *ac_forw;
|
||||
struct null_node *ac_back;
|
||||
};
|
||||
|
||||
static struct null_node_cache null_node_cache[NNULLNODECACHE];
|
||||
#define NULL_NHASH(vp) \
|
||||
(&null_node_hashtbl[(((u_long)vp)>>LOG2_SIZEVNODE) & null_node_hash])
|
||||
LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl;
|
||||
u_long null_node_hash;
|
||||
|
||||
/*
|
||||
* Initialise cache headers
|
||||
*/
|
||||
nullfs_init()
|
||||
{
|
||||
struct null_node_cache *ac;
|
||||
|
||||
#ifdef NULLFS_DIAGNOSTIC
|
||||
printf("nullfs_init\n"); /* printed during system boot */
|
||||
#endif
|
||||
|
||||
for (ac = null_node_cache; ac < null_node_cache + NNULLNODECACHE; ac++)
|
||||
ac->ac_forw = ac->ac_back = (struct null_node *) ac;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute hash list for given lower vnode
|
||||
*/
|
||||
static struct null_node_cache *
|
||||
null_node_hash(lowervp)
|
||||
struct vnode *lowervp;
|
||||
{
|
||||
|
||||
return (&null_node_cache[NULL_NHASH(lowervp)]);
|
||||
null_node_hashtbl = hashinit(NNULLNODECACHE, M_CACHE, &null_node_hash);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -104,7 +85,7 @@ null_node_find(mp, lowervp)
|
||||
struct mount *mp;
|
||||
struct vnode *lowervp;
|
||||
{
|
||||
struct null_node_cache *hd;
|
||||
struct null_node_hashhead *hd;
|
||||
struct null_node *a;
|
||||
struct vnode *vp;
|
||||
|
||||
@ -114,9 +95,9 @@ null_node_find(mp, lowervp)
|
||||
* the lower vnode. If found, the increment the null_node
|
||||
* reference count (but NOT the lower vnode's VREF counter).
|
||||
*/
|
||||
hd = null_node_hash(lowervp);
|
||||
hd = NULL_NHASH(lowervp);
|
||||
loop:
|
||||
for (a = hd->ac_forw; a != (struct null_node *) hd; a = a->null_forw) {
|
||||
for (a = hd->lh_first; a != 0; a = a->null_hash.le_next) {
|
||||
if (a->null_lowervp == lowervp && NULLTOV(a)->v_mount == mp) {
|
||||
vp = NULLTOV(a);
|
||||
/*
|
||||
@ -147,7 +128,7 @@ null_node_alloc(mp, lowervp, vpp)
|
||||
struct vnode *lowervp;
|
||||
struct vnode **vpp;
|
||||
{
|
||||
struct null_node_cache *hd;
|
||||
struct null_node_hashhead *hd;
|
||||
struct null_node *xp;
|
||||
struct vnode *othervp, *vp;
|
||||
int error;
|
||||
@ -174,8 +155,8 @@ null_node_alloc(mp, lowervp, vpp)
|
||||
return 0;
|
||||
};
|
||||
VREF(lowervp); /* Extra VREF will be vrele'd in null_node_create */
|
||||
hd = null_node_hash(lowervp);
|
||||
insque(xp, hd);
|
||||
hd = NULL_NHASH(lowervp);
|
||||
LIST_INSERT_HEAD(hd, xp, null_hash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: null_vnops.c,v 1.3 1994/07/20 07:37:25 mycroft Exp $ */
|
||||
/* $NetBSD: null_vnops.c,v 1.4 1994/08/19 11:25:37 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -373,7 +373,7 @@ null_reclaim(ap)
|
||||
*/
|
||||
/* After this assignment, this node will not be re-used. */
|
||||
xp->null_lowervp = NULL;
|
||||
remque(xp);
|
||||
LIST_REMOVE(xp, null_hash);
|
||||
FREE(vp->v_data, M_TEMP);
|
||||
vp->v_data = NULL;
|
||||
vrele (lowervp);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umap.h,v 1.2 1994/06/29 06:35:09 cgd Exp $ */
|
||||
/* $NetBSD: umap.h,v 1.3 1994/08/19 11:25:40 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -68,8 +68,7 @@ struct umap_mount {
|
||||
* A cache of vnode references
|
||||
*/
|
||||
struct umap_node {
|
||||
struct umap_node *umap_forw; /* Hash chain */
|
||||
struct umap_node *umap_back;
|
||||
LIST_ENTRY(umap_node) umap_hash; /* Hash list */
|
||||
struct vnode *umap_lowervp; /* Aliased vnode - VREFed once */
|
||||
struct vnode *umap_vnode; /* Back pointer to vnode/umap_node */
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umap_subr.c,v 1.2 1994/06/29 06:35:11 cgd Exp $ */
|
||||
/* $NetBSD: umap_subr.c,v 1.3 1994/08/19 11:25:41 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -51,7 +51,6 @@
|
||||
|
||||
#define LOG2_SIZEVNODE 7 /* log2(sizeof struct vnode) */
|
||||
#define NUMAPNODECACHE 16
|
||||
#define UMAP_NHASH(vp) ((((u_long) vp)>>LOG2_SIZEVNODE) & (NUMAPNODECACHE-1))
|
||||
|
||||
/*
|
||||
* Null layer cache:
|
||||
@ -61,39 +60,21 @@
|
||||
* alias is removed the target vnode is vrele'd.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Cache head
|
||||
*/
|
||||
struct umap_node_cache {
|
||||
struct umap_node *ac_forw;
|
||||
struct umap_node *ac_back;
|
||||
};
|
||||
|
||||
static struct umap_node_cache umap_node_cache[NUMAPNODECACHE];
|
||||
#define UMAP_NHASH(vp) \
|
||||
(&umap_node_hashtbl[(((u_long)vp)>>LOG2_SIZEVNODE) & umap_node_hash])
|
||||
LIST_HEAD(umap_node_hashhead, umap_node) *umap_node_hashtbl;
|
||||
u_long umap_node_hash;
|
||||
|
||||
/*
|
||||
* Initialise cache headers
|
||||
*/
|
||||
umapfs_init()
|
||||
{
|
||||
struct umap_node_cache *ac;
|
||||
|
||||
#ifdef UMAPFS_DIAGNOSTIC
|
||||
printf("umapfs_init\n"); /* printed during system boot */
|
||||
#endif
|
||||
|
||||
for (ac = umap_node_cache; ac < umap_node_cache + NUMAPNODECACHE; ac++)
|
||||
ac->ac_forw = ac->ac_back = (struct umap_node *) ac;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute hash list for given target vnode
|
||||
*/
|
||||
static struct umap_node_cache *
|
||||
umap_node_hash(targetvp)
|
||||
struct vnode *targetvp;
|
||||
{
|
||||
|
||||
return (&umap_node_cache[UMAP_NHASH(targetvp)]);
|
||||
umap_node_hashtbl = hashinit(NUMAPNODECACHE, M_CACHE, &umap_node_hash);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -152,7 +133,7 @@ umap_node_find(mp, targetvp)
|
||||
struct mount *mp;
|
||||
struct vnode *targetvp;
|
||||
{
|
||||
struct umap_node_cache *hd;
|
||||
struct umap_node_hashhead *hd;
|
||||
struct umap_node *a;
|
||||
struct vnode *vp;
|
||||
|
||||
@ -166,10 +147,9 @@ umap_node_find(mp, targetvp)
|
||||
* the target vnode. If found, the increment the umap_node
|
||||
* reference count (but NOT the target vnode's VREF counter).
|
||||
*/
|
||||
hd = umap_node_hash(targetvp);
|
||||
|
||||
loop:
|
||||
for (a = hd->ac_forw; a != (struct umap_node *) hd; a = a->umap_forw) {
|
||||
hd = UMAP_NHASH(targetvp);
|
||||
loop:
|
||||
for (a = hd->lh_first; a != 0; a = a->umap_hash.le_next) {
|
||||
if (a->umap_lowervp == targetvp &&
|
||||
a->umap_vnode->v_mount == mp) {
|
||||
vp = UMAPTOV(a);
|
||||
@ -206,7 +186,7 @@ umap_node_alloc(mp, lowervp, vpp)
|
||||
struct vnode *lowervp;
|
||||
struct vnode **vpp;
|
||||
{
|
||||
struct umap_node_cache *hd;
|
||||
struct umap_node_hashhead *hd;
|
||||
struct umap_node *xp;
|
||||
struct vnode *othervp, *vp;
|
||||
int error;
|
||||
@ -234,8 +214,8 @@ umap_node_alloc(mp, lowervp, vpp)
|
||||
return (0);
|
||||
}
|
||||
VREF(lowervp); /* Extra VREF will be vrele'd in umap_node_create */
|
||||
hd = umap_node_hash(lowervp);
|
||||
insque(xp, hd);
|
||||
hd = UMAP_NHASH(lowervp);
|
||||
LIST_INSERT_HEAD(hd, xp, umap_hash);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umap_vnops.c,v 1.2 1994/06/29 06:35:14 cgd Exp $ */
|
||||
/* $NetBSD: umap_vnops.c,v 1.3 1994/08/19 11:25:42 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -359,7 +359,7 @@ umap_reclaim(ap)
|
||||
|
||||
/* After this assignment, this node will not be re-used. */
|
||||
xp->umap_lowervp = NULL;
|
||||
remque(xp);
|
||||
LIST_REMOVE(xp, umap_hash);
|
||||
FREE(vp->v_data, M_TEMP);
|
||||
vp->v_data = NULL;
|
||||
vrele(lowervp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user