diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1997-11-06 05:59:40 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1997-11-06 05:59:40 +0000 |
commit | 4e165724f1631d1deee6fd89b941fabdbcc855d4 (patch) | |
tree | 3aca36af68e90377984b00e9f0050674b0763db5 /sys/isofs/cd9660/cd9660_node.c | |
parent | fec1be888534eb37405f6bf7a195f28670e1392b (diff) |
Updates for VFS Lite 2 + soft update.
Diffstat (limited to 'sys/isofs/cd9660/cd9660_node.c')
-rw-r--r-- | sys/isofs/cd9660/cd9660_node.c | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/sys/isofs/cd9660/cd9660_node.c b/sys/isofs/cd9660/cd9660_node.c index e7d318e2022..712ebfaa4a3 100644 --- a/sys/isofs/cd9660/cd9660_node.c +++ b/sys/isofs/cd9660/cd9660_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_node.c,v 1.5 1997/10/06 20:19:43 deraadt Exp $ */ +/* $OpenBSD: cd9660_node.c,v 1.6 1997/11/06 05:58:10 csapuntz Exp $ */ /* $NetBSD: cd9660_node.c,v 1.15 1996/02/09 21:31:58 christos Exp $ */ /*- @@ -63,6 +63,7 @@ struct iso_node **isohashtbl; u_long isohash; #define INOHASH(device, inum) (((device) + ((inum)>>12)) & isohash) +struct simplelock cd9660_ihash_slock; #ifdef ISODEVMAP struct iso_node **idvhashtbl; @@ -73,18 +74,20 @@ u_long idvhash; int prtactive; /* 1 => print out reclaim of active vnodes */ static u_int cd9660_chars2ui __P((u_char *, int)); - /* * Initialize hash links for inodes and dnodes. */ -void -cd9660_init() +int +cd9660_init(vfsp) + struct vfsconf *vfsp; { isohashtbl = hashinit(desiredvnodes, M_ISOFSMNT, &isohash); + simple_lock_init(&cd9660_ihash_slock); #ifdef ISODEVMAP idvhashtbl = hashinit(desiredvnodes / 8, M_ISOFSMNT, &idvhash); #endif + return (0); } #ifdef ISODEVMAP @@ -105,6 +108,7 @@ iso_dmap(device, inum, create) return (NULL); if (inum == dp->i_number && device == dp->i_dev) return (dp); + } if (!create) return (NULL); @@ -130,7 +134,7 @@ iso_dunmap(device) struct iso_dnode **dpp, *dp, *dq; for (dpp = idvhashtbl; dpp <= idvhashtbl + idvhash; dpp++) { - for (dp = *dpp; dp != NULL; dp = dq) + for (dp = *dpp; dp != NULL; dp = dq) { dq = dp->d_next; if (device == dp->i_dev) { if (dq) @@ -148,30 +152,28 @@ iso_dunmap(device) * to it. If it is in core, but locked, wait for it. */ struct vnode * -cd9660_ihashget(device, inum) - dev_t device; +cd9660_ihashget(dev, inum) + dev_t dev; ino_t inum; { - register struct iso_node *ip; + struct proc *p = curproc; /* XXX */ + struct iso_node *ip; struct vnode *vp; - for (;;) - for (ip = isohashtbl[INOHASH(device, inum)];; ip = ip->i_next) { - if (ip == NULL) - return (NULL); - if (inum == ip->i_number && device == ip->i_dev) { - if (ip->i_flag & IN_LOCKED) { - ip->i_flag |= IN_WANTED; - sleep(ip, PINOD); - break; - } - vp = ITOV(ip); - if (!vget(vp, 1)) - return (vp); - break; - } - } - /* NOTREACHED */ +loop: + simple_lock(&cd9660_ihash_slock); + for (ip = isohashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) { + if (inum == ip->i_number && dev == ip->i_dev) { + vp = ITOV(ip); + simple_lock(&vp->v_interlock); + simple_unlock(&cd9660_ihash_slock); + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + goto loop; + return (vp); + } + } + simple_unlock(&cd9660_ihash_slock); + return (NULL); } /* @@ -181,21 +183,19 @@ void cd9660_ihashins(ip) struct iso_node *ip; { + struct proc *p = curproc; struct iso_node **ipp, *iq; + simple_lock(&cd9660_ihash_slock); ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)]; if ((iq = *ipp) != NULL) iq->i_prev = &ip->i_next; ip->i_next = iq; ip->i_prev = ipp; *ipp = ip; - if (ip->i_flag & IN_LOCKED) - panic("cd9660_ihashins: already locked"); - if (curproc) - ip->i_lockholder = curproc->p_pid; - else - ip->i_lockholder = -1; - ip->i_flag |= IN_LOCKED; + simple_unlock(&cd9660_ihash_slock); + + lockmgr(&ip->i_lock, LK_EXCLUSIVE, 0, p); } /* @@ -207,6 +207,7 @@ cd9660_ihashrem(ip) { register struct iso_node *iq; + simple_lock(&cd9660_ihash_slock); if ((iq = ip->i_next) != NULL) iq->i_prev = ip->i_prev; *ip->i_prev = iq; @@ -214,6 +215,7 @@ cd9660_ihashrem(ip) ip->i_next = NULL; ip->i_prev = NULL; #endif + simple_unlock(&cd9660_ihash_slock); } /* @@ -226,8 +228,10 @@ cd9660_inactive(v) { struct vop_inactive_args /* { struct vnode *a_vp; + struct proc *a_p; } */ *ap = v; struct vnode *vp = ap->a_vp; + struct proc *p = ap->a_p; register struct iso_node *ip = VTOI(vp); int error = 0; @@ -235,12 +239,14 @@ cd9660_inactive(v) vprint("cd9660_inactive: pushing active", vp); ip->i_flag = 0; + VOP_UNLOCK(vp, 0, p); /* * If we are done with the inode, reclaim it * so that it can be reused immediately. */ - if (vp->v_usecount == 0 && ip->inode.iso_mode == 0) - vgone(vp); + if (ip->inode.iso_mode == 0) + vrecycle(vp, (struct simplelock *)0, p); + return error; } |