diff options
author | dyson <dyson@FreeBSD.org> | 1997-02-10 02:22:35 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1997-02-10 02:22:35 +0000 |
commit | 10f666af84d48e89e4e2960415c9b616fce4077f (patch) | |
tree | 88a944de263165091f0a18abeedbaaccec532407 /sys/fs/nullfs/null_subr.c | |
parent | 0960d7e91af3428ffba89b42228d82d8afaa0389 (diff) | |
download | FreeBSD-src-10f666af84d48e89e4e2960415c9b616fce4077f.zip FreeBSD-src-10f666af84d48e89e4e2960415c9b616fce4077f.tar.gz |
This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.
The system boots and can mount UFS filesystems.
Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
Mount_std mounts will not work until the getfsent
library routine is changed.
Reviewed by: various people
Submitted by: Jeffery Hsu <hsu@freebsd.org>
Diffstat (limited to 'sys/fs/nullfs/null_subr.c')
-rw-r--r-- | sys/fs/nullfs/null_subr.c | 61 |
1 files changed, 20 insertions, 41 deletions
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c index a14a7e4..4418631 100644 --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -33,13 +33,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)null_subr.c 8.4 (Berkeley) 1/21/94 + * @(#)null_subr.c 8.7 (Berkeley) 5/14/95 * * $FreeBSD$ */ #include <sys/param.h> #include <sys/systm.h> +#include <sys/proc.h> #include <sys/time.h> #include <sys/types.h> #include <sys/vnode.h> @@ -48,11 +49,8 @@ #include <sys/malloc.h> #include <miscfs/nullfs/null.h> -extern int nullfs_init __P((void)); - #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: @@ -62,51 +60,32 @@ extern int nullfs_init __P((void)); * 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; static int null_node_alloc __P((struct mount *mp, struct vnode *lowervp, struct vnode **vpp)); static struct vnode * null_node_find __P((struct mount *mp, struct vnode *lowervp)); -static struct null_node_cache * - null_node_hash __P((struct vnode *lowervp)); /* * Initialise cache headers */ int -nullfs_init() +nullfs_init(vfsp) + struct vfsconf *vfsp; { - 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; + null_node_hashtbl = hashinit(NNULLNODECACHE, M_CACHE, &null_node_hash); return (0); } /* - * 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)]); -} - -/* * Return a VREF'ed alias for lower vnode if already exists, else 0. */ static struct vnode * @@ -114,7 +93,8 @@ null_node_find(mp, lowervp) struct mount *mp; struct vnode *lowervp; { - struct null_node_cache *hd; + struct proc *p = curproc; /* XXX */ + struct null_node_hashhead *hd; struct null_node *a; struct vnode *vp; @@ -124,9 +104,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); /* @@ -134,7 +114,7 @@ loop: * stuff, but we don't want to lock * the lower node. */ - if (vget(vp, 0)) { + if (vget(vp, 0, p)) { printf ("null_node_find: vget failed.\n"); goto loop; }; @@ -157,7 +137,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; @@ -194,8 +174,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; } @@ -250,9 +230,8 @@ null_node_create(mp, lowervp, newvpp) #ifdef DIAGNOSTIC if (lowervp->v_usecount < 1) { /* Should never happen... */ - vprint ("null_node_create: alias ",aliasvp); - vprint ("null_node_create: lower ",lowervp); - printf ("null_node_create: lower has 0 usecount.\n"); + vprint ("null_node_create: alias ", aliasvp); + vprint ("null_node_create: lower ", lowervp); panic ("null_node_create: lower has 0 usecount."); }; #endif |