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/miscfs/umapfs | |
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/miscfs/umapfs')
-rw-r--r-- | sys/miscfs/umapfs/umap.h | 5 | ||||
-rw-r--r-- | sys/miscfs/umapfs/umap_subr.c | 61 | ||||
-rw-r--r-- | sys/miscfs/umapfs/umap_vfsops.c | 21 | ||||
-rw-r--r-- | sys/miscfs/umapfs/umap_vnops.c | 49 |
4 files changed, 78 insertions, 58 deletions
diff --git a/sys/miscfs/umapfs/umap.h b/sys/miscfs/umapfs/umap.h index db1efd4..54ae097 100644 --- a/sys/miscfs/umapfs/umap.h +++ b/sys/miscfs/umapfs/umap.h @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)umap.h 8.3 (Berkeley) 1/21/94 + * @(#)umap.h 8.4 (Berkeley) 8/20/94 * * $FreeBSD$ */ @@ -67,8 +67,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 */ }; diff --git a/sys/miscfs/umapfs/umap_subr.c b/sys/miscfs/umapfs/umap_subr.c index 8333943..3b3629d 100644 --- a/sys/miscfs/umapfs/umap_subr.c +++ b/sys/miscfs/umapfs/umap_subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 1993, 1995 * The Regents of the University of California. All rights reserved. * * This code is derived from software donated to Berkeley by @@ -33,13 +33,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)umap_subr.c 8.6 (Berkeley) 1/26/94 + * @(#)umap_subr.c 8.9 (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/umapfs/umap.h> -extern int umapfs_init __P((void)); - #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: @@ -62,52 +60,33 @@ extern int umapfs_init __P((void)); * 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; static u_long umap_findid __P((u_long id, u_long map[][2], int nentries)); static int umap_node_alloc __P((struct mount *mp, struct vnode *lowervp, struct vnode **vpp)); static struct vnode * umap_node_find __P((struct mount *mp, struct vnode *targetvp)); -static struct umap_node_cache * - umap_node_hash __P((struct vnode *targetvp)); /* * Initialise cache headers */ int -umapfs_init() +umapfs_init(vfsp) + struct vfsconf *vfsp; { - 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; + umap_node_hashtbl = hashinit(NUMAPNODECACHE, M_CACHE, &umap_node_hash); return (0); } /* - * 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_findid is called by various routines in umap_vnodeops.c to * find a user or group id in a map. */ @@ -163,7 +142,8 @@ umap_node_find(mp, targetvp) struct mount *mp; struct vnode *targetvp; { - struct umap_node_cache *hd; + struct proc *p = curproc; /* XXX */ + struct umap_node_hashhead *hd; struct umap_node *a; struct vnode *vp; @@ -177,10 +157,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); @@ -189,7 +168,7 @@ umap_node_find(mp, targetvp) * stuff, but we don't want to lock * the lower node. */ - if (vget(vp, 0)) { + if (vget(vp, 0, p)) { #ifdef UMAPFS_DIAGNOSTIC printf ("umap_node_find: vget failed.\n"); #endif @@ -217,7 +196,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; @@ -257,8 +236,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); } diff --git a/sys/miscfs/umapfs/umap_vfsops.c b/sys/miscfs/umapfs/umap_vfsops.c index 517c291..897e2ce 100644 --- a/sys/miscfs/umapfs/umap_vfsops.c +++ b/sys/miscfs/umapfs/umap_vfsops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 1993, 1995 * The Regents of the University of California. All rights reserved. * * This code is derived from software donated to Berkeley by @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)umap_vfsops.c 8.3 (Berkeley) 1/21/94 + * @(#)umap_vfsops.c 8.8 (Berkeley) 5/14/95 * * $FreeBSD$ */ @@ -46,6 +46,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/proc.h> #include <sys/time.h> #include <sys/types.h> #include <sys/vnode.h> @@ -54,7 +55,7 @@ #include <sys/malloc.h> #include <miscfs/umapfs/umap.h> -extern int umapfs_init __P((void)); +extern int umapfs_init __P((struct vfsconf *)); static int umapfs_fhtovp __P((struct mount *mp, struct fid *fidp, struct mbuf *nam, struct vnode **vpp, @@ -187,7 +188,7 @@ umapfs_mount(mp, path, data, ndp, p) /* * Unlock the node (either the lower or the alias) */ - VOP_UNLOCK(vp); + VOP_UNLOCK(vp, 0, p); /* * Make sure the node alias worked */ @@ -207,7 +208,7 @@ umapfs_mount(mp, path, data, ndp, p) if (UMAPVPTOLOWERVP(umapm_rootvp)->v_mount->mnt_flag & MNT_LOCAL) mp->mnt_flag |= MNT_LOCAL; mp->mnt_data = (qaddr_t) amp; - getnewfsid(mp, MOUNT_LOFS); + vfs_getnewfsid(mp); (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); @@ -253,12 +254,8 @@ umapfs_unmount(mp, mntflags, p) printf("umapfs_unmount(mp = %x)\n", mp); #endif - if (mntflags & MNT_FORCE) { - /* lofs can never be rootfs so don't check for it */ - if (!doforce) - return (EINVAL); + if (mntflags & MNT_FORCE) flags |= FORCECLOSE; - } /* * Clear out buffer cache. I don't think we @@ -300,6 +297,7 @@ umapfs_root(mp, vpp) struct mount *mp; struct vnode **vpp; { + struct proc *p = curproc; /* XXX */ struct vnode *vp; #ifdef UMAPFS_DIAGNOSTIC @@ -314,7 +312,7 @@ umapfs_root(mp, vpp) */ vp = MOUNTTOUMAPMOUNT(mp)->umapm_rootvp; VREF(vp); - VOP_LOCK(vp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); *vpp = vp; return (0); } @@ -429,4 +427,3 @@ static struct vfsops umap_vfsops = { }; VFS_SET(umap_vfsops, umap, MOUNT_UMAP, VFCF_LOOPBACK); - diff --git a/sys/miscfs/umapfs/umap_vnops.c b/sys/miscfs/umapfs/umap_vnops.c index 7c14cda..17064f4 100644 --- a/sys/miscfs/umapfs/umap_vnops.c +++ b/sys/miscfs/umapfs/umap_vnops.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)umap_vnops.c 8.3 (Berkeley) 1/5/94 + * @(#)umap_vnops.c 8.6 (Berkeley) 5/22/95 * $FreeBSD$ */ @@ -336,10 +336,52 @@ umap_getattr(ap) return (0); } +/* + * We need to process our own vnode lock and then clear the + * interlock flag as it applies only to our vnode, not the + * vnodes below us on the stack. + */ +int +umap_lock(ap) + struct vop_lock_args /* { + struct vnode *a_vp; + int a_flags; + struct proc *a_p; + } */ *ap; +{ + + vop_nolock(ap); + if ((ap->a_flags & LK_TYPE_MASK) == LK_DRAIN) + return (0); + ap->a_flags &= ~LK_INTERLOCK; + return (null_bypass(ap)); +} + +/* + * We need to process our own vnode unlock and then clear the + * interlock flag as it applies only to our vnode, not the + * vnodes below us on the stack. + */ +int +umap_unlock(ap) + struct vop_unlock_args /* { + struct vnode *a_vp; + int a_flags; + struct proc *a_p; + } */ *ap; +{ + struct vnode *vp = ap->a_vp; + + vop_nounlock(ap); + ap->a_flags &= ~LK_INTERLOCK; + return (null_bypass(ap)); +} + static int umap_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; + struct proc *a_p; } */ *ap; { /* @@ -349,6 +391,7 @@ umap_inactive(ap) * cache and reusable. * */ + VOP_UNLOCK(ap->a_vp, 0, ap->a_p); return (0); } @@ -364,7 +407,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); @@ -487,6 +530,8 @@ static struct vnodeopv_entry_desc umap_vnodeop_entries[] = { { &vop_default_desc, (vop_t *)umap_bypass }, { &vop_getattr_desc, (vop_t *)umap_getattr }, + { &vop_lock_desc, (vop_t *)umap_lock }, + { &vop_unlock_desc, (vop_t *)umap_unlock }, { &vop_inactive_desc, (vop_t *)umap_inactive }, { &vop_reclaim_desc, (vop_t *)umap_reclaim }, { &vop_print_desc, (vop_t *)umap_print }, |