summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-12-05 00:24:37 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-12-05 00:24:37 +0000
commit700bfd46672d212a961c40855e2cdae0ac91731a (patch)
treed0be3ff7a803a2b4dae00819acfeb5a7eac1cba2 /sys
parentfa0689f92d18b7b6403a25d4ccf5fe1e898bc4ac (diff)
Break out the part that lowers v_holdcnt in brelvp into an own function
and make it and vhold into public interfaces.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_subr.c59
-rw-r--r--sys/sys/vnode.h5
2 files changed, 37 insertions, 27 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 6f2c1be1388..4ff7c36f128 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.75 2001/11/29 02:54:10 art Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.76 2001/12/05 00:24:36 art Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -858,14 +858,12 @@ vrele(vp)
VOP_INACTIVE(vp, p);
}
-void vhold __P((struct vnode *vp));
-
/*
* Page or buffer structure gets a reference.
+ * Must be called at splbio();
*/
void
-vhold(vp)
- register struct vnode *vp;
+vhold(struct vnode *vp)
{
/*
@@ -885,6 +883,34 @@ vhold(vp)
}
/*
+ * Release a vhold reference.
+ * Must be called at splbio();
+ */
+void
+vholdrele(struct vnode *vp)
+{
+ simple_lock(&vp->v_interlock);
+#ifdef DIAGNOSTIC
+ if (vp->v_holdcnt == 0)
+ panic("vholdrele: 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) {
+ simple_lock(&vnode_free_list_slock);
+ TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist);
+ TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
+ simple_unlock(&vnode_free_list_slock);
+ }
+ simple_unlock(&vp->v_interlock);
+}
+
+/*
* Remove any vnodes in the vnode table belonging to mount point mp.
*
* If MNT_NOFORCE is specified, there should not be any active ones,
@@ -2162,8 +2188,7 @@ bgetvp(vp, bp)
* Manipulates vnode buffer queues. Must be called at splbio().
*/
void
-brelvp(bp)
- struct buf *bp;
+brelvp(struct buf *bp)
{
struct vnode *vp;
@@ -2183,25 +2208,7 @@ brelvp(bp)
}
bp->b_vp = NULL;
- simple_lock(&vp->v_interlock);
-#ifdef DIAGNOSTIC
- if (vp->v_holdcnt == 0)
- panic("brelvp: 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) {
- simple_lock(&vnode_free_list_slock);
- TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist);
- TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
- simple_unlock(&vnode_free_list_slock);
- }
- simple_unlock(&vp->v_interlock);
+ vholdrele(vp);
}
/*
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 6d7d28f9a02..9e6c38cebc5 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnode.h,v 1.43 2001/12/04 22:44:32 art Exp $ */
+/* $OpenBSD: vnode.h,v 1.44 2001/12/05 00:24:36 art Exp $ */
/* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */
/*
@@ -253,6 +253,9 @@ vref(vp)
}
#endif /* DIAGNOSTIC */
+void vhold __P((struct vnode *));
+void vholdrele __P((struct vnode *));
+
#define NULLVP ((struct vnode *)NULL)
/*