diff options
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 13c70890ccc..4ace1adde8d 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.315 2022/03/27 16:19:39 semarie Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.316 2022/08/12 14:30:52 visa Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -662,16 +662,16 @@ vget(struct vnode *vp, int flags) } mtx_leave(&vnode_mtx); + s = splbio(); onfreelist = vp->v_bioflag & VBIOONFREELIST; if (vp->v_usecount == 0 && onfreelist) { - s = splbio(); if (vp->v_holdcnt > 0) TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist); else TAILQ_REMOVE(&vnode_free_list, vp, v_freelist); vp->v_bioflag &= ~VBIOONFREELIST; - splx(s); } + splx(s); vp->v_usecount++; if (flags & LK_TYPE_MASK) { @@ -749,6 +749,7 @@ void vput(struct vnode *vp) { struct proc *p = curproc; + int s; #ifdef DIAGNOSTIC if (vp == NULL) @@ -777,8 +778,10 @@ vput(struct vnode *vp) VOP_INACTIVE(vp, p); + s = splbio(); if (vp->v_usecount == 0 && !(vp->v_bioflag & VBIOONFREELIST)) vputonfreelist(vp); + splx(s); } /* @@ -790,6 +793,7 @@ int vrele(struct vnode *vp) { struct proc *p = curproc; + int s; #ifdef DIAGNOSTIC if (vp == NULL) @@ -822,8 +826,10 @@ vrele(struct vnode *vp) VOP_INACTIVE(vp, p); + s = splbio(); if (vp->v_usecount == 0 && !(vp->v_bioflag & VBIOONFREELIST)) vputonfreelist(vp); + splx(s); return (1); } @@ -831,6 +837,10 @@ vrele(struct vnode *vp) void vhold(struct vnode *vp) { + int s; + + s = splbio(); + /* * If it is on the freelist and the hold count is currently * zero, move it to the hold list. @@ -841,12 +851,18 @@ vhold(struct vnode *vp) TAILQ_INSERT_TAIL(&vnode_hold_list, vp, v_freelist); } vp->v_holdcnt++; + + splx(s); } /* Lose interest in a vnode. */ void vdrop(struct vnode *vp) { + int s; + + s = splbio(); + #ifdef DIAGNOSTIC if (vp->v_holdcnt == 0) panic("vdrop: zero holdcnt"); @@ -863,6 +879,8 @@ vdrop(struct vnode *vp) TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist); TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); } + + splx(s); } /* @@ -909,6 +927,7 @@ vflush_vnode(struct vnode *vp, void *arg) { struct vflush_args *va = arg; struct proc *p = curproc; + int empty, s; if (vp == va->skipvp) { return (0); @@ -958,8 +977,11 @@ vflush_vnode(struct vnode *vp, void *arg) * XXX Might be nice to check per-fs "inode" flags, but * generally the filesystem is sync'd already, right? */ - if ((va->flags & IGNORECLEAN) && - LIST_EMPTY(&vp->v_dirtyblkhd)) + s = splbio(); + empty = (va->flags & IGNORECLEAN) && LIST_EMPTY(&vp->v_dirtyblkhd); + splx(s); + + if (empty) return (0); #ifdef DEBUG_SYSCTL @@ -992,6 +1014,7 @@ void vclean(struct vnode *vp, int flags, struct proc *p) { int active, do_wakeup = 0; + int s; /* * Check to see if the vnode is in use. @@ -1066,9 +1089,11 @@ vclean(struct vnode *vp, int flags, struct proc *p) if (active) { vp->v_usecount--; if (vp->v_usecount == 0) { + s = splbio(); if (vp->v_holdcnt > 0) panic("vclean: not clean"); vputonfreelist(vp); + splx(s); } } cache_purge(vp); @@ -1125,6 +1150,7 @@ vgonel(struct vnode *vp, struct proc *p) { struct vnode *vq; struct vnode *vx; + int s; KASSERT(vp->v_uvcount == 0); @@ -1192,12 +1218,9 @@ vgonel(struct vnode *vp, struct proc *p) * Move onto the free list, unless we were called from * getnewvnode and we're not on any free list */ + s = splbio(); if (vp->v_usecount == 0 && (vp->v_bioflag & VBIOONFREELIST)) { - int s; - - s = splbio(); - if (vp->v_holdcnt > 0) panic("vgonel: not clean"); @@ -1205,8 +1228,8 @@ vgonel(struct vnode *vp, struct proc *p) TAILQ_REMOVE(&vnode_free_list, vp, v_freelist); TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); } - splx(s); } + splx(s); } /* |