diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-04-28 09:53:54 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-04-28 09:53:54 +0000 |
commit | 4887a72e0faf0bb613766e1087f0588d3e6f1efb (patch) | |
tree | 5208e287bba068f9bc6327702566be5413feb7b8 /sys/miscfs/deadfs | |
parent | 176253037126c3bd71b12369fe410a948e26b2f2 (diff) |
Introduce a global vnode_mtx and use it to make vn_lock() safe to be called
without the KERNEL_LOCK.
This moves VXLOCK and VXWANT to a mutex protected v_lflag field and also
v_lockcount is protected by this mutex.
The vn_lock() dance is overly complex and all of this should probably replaced
by a proper lock on the vnode but such a diff is a lot more complex. This
is an intermediate step so that at least some calls can be modified to grab
the KERNEL_LOCK later or not at all.
OK mpi@
Diffstat (limited to 'sys/miscfs/deadfs')
-rw-r--r-- | sys/miscfs/deadfs/dead_vnops.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/miscfs/deadfs/dead_vnops.c b/sys/miscfs/deadfs/dead_vnops.c index 54083f509b2..8aada87b09e 100644 --- a/sys/miscfs/deadfs/dead_vnops.c +++ b/sys/miscfs/deadfs/dead_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dead_vnops.c,v 1.34 2021/03/24 16:11:32 semarie Exp $ */ +/* $OpenBSD: dead_vnops.c,v 1.35 2021/04/28 09:53:53 claudio Exp $ */ /* $NetBSD: dead_vnops.c,v 1.16 1996/02/13 13:12:48 mycroft Exp $ */ /* @@ -285,10 +285,12 @@ chkvnlock(struct vnode *vp) { int locked = 0; - while (vp->v_flag & VXLOCK) { - vp->v_flag |= VXWANT; - tsleep_nsec(vp, PINOD, "chkvnlock", INFSLP); + mtx_enter(&vnode_mtx); + while (vp->v_lflag & VXLOCK) { + vp->v_lflag |= VXWANT; + msleep_nsec(vp, &vnode_mtx, PINOD, "chkvnlock", INFSLP); locked = 1; } + mtx_leave(&vnode_mtx); return (locked); } |