summaryrefslogtreecommitdiffstats
path: root/sys/fs/umapfs/umap_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/umapfs/umap_subr.c')
-rw-r--r--sys/fs/umapfs/umap_subr.c61
1 files changed, 20 insertions, 41 deletions
diff --git a/sys/fs/umapfs/umap_subr.c b/sys/fs/umapfs/umap_subr.c
index 8333943..3b3629d 100644
--- a/sys/fs/umapfs/umap_subr.c
+++ b/sys/fs/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);
}
OpenPOWER on IntegriCloud