diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2008-07-05 12:48:04 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2008-07-05 12:48:04 +0000 |
commit | 6b3da765106032c6f1c99619a59df9f495c94d9f (patch) | |
tree | 6f62c06e403532f7d3862a3ee4d9bdadf6c74500 /sys/kern/vfs_subr.c | |
parent | d8f66231c88c14a36f6f9c87c9c01cbe761920d3 (diff) |
re-introduce vdrop() to signal a lost intrest in a vnode;
ok art@
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index d7e525a81ee..34451d2e95f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.172 2008/06/14 10:55:21 mk Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.173 2008/07/05 12:48:03 thib Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -94,6 +94,8 @@ struct freelst vnode_free_list; /* vnode free list */ struct mntlist mountlist; /* mounted filesystem list */ void vclean(struct vnode *, int, struct proc *); +void vhold(struct vnode *); +void vdrop(struct vnode *); void insmntque(struct vnode *, struct mount *); int getdevvp(dev_t, struct vnode **, enum vtype); @@ -729,11 +731,7 @@ vrele(struct vnode *vp) vputonfreelist(vp); } -void vhold(struct vnode *vp); - -/* - * Page or buffer structure gets a reference. - */ +/* Page or buffer structure gets a reference. */ void vhold(struct vnode *vp) { @@ -749,6 +747,28 @@ vhold(struct vnode *vp) vp->v_holdcnt++; } +/* Lose interest in a vnode. */ +void +vdrop(struct vnode *vp) +{ +#ifdef DIAGNOSTIC + if (vp->v_holdcnt == 0) + panic("vdrop: zero holdcnt"); +#endif + + vp->v_holdcnt--; + + /* + * If it is on the holdlist and the hold count drops to + * zero, move it to the free list. + */ + if ((vp->v_bioflag & VBIOONFREELIST) && + vp->v_holdcnt == 0 && vp->v_usecount == 0) { + TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist); + TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); + } +} + /* * Remove any vnodes in the vnode table belonging to mount point mp. * @@ -1259,7 +1279,6 @@ vfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, ret = sysctl_rdstruct(oldp, oldlenp, newp, &bcstats, sizeof(struct bcachestats)); return(ret); - } return (EOPNOTSUPP); } @@ -1952,23 +1971,9 @@ brelvp(struct buf *bp) vp->v_bioflag &= ~VBIOONSYNCLIST; LIST_REMOVE(vp, v_synclist); } - bp->b_vp = (struct vnode *) 0; - -#ifdef DIAGNOSTIC - if (vp->v_holdcnt == 0) - panic("brelvp: holdcnt"); -#endif - vp->v_holdcnt--; + bp->b_vp = NULL; - /* - * If it is on the holdlist and the hold count drops to - * zero, move it to the free list. - */ - if ((vp->v_bioflag & VBIOONFREELIST) && - vp->v_holdcnt == 0 && vp->v_usecount == 0) { - TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist); - TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); - } + vdrop(vp); } /* |