From 05ee8c212a923ffe0a321ea1bf1cca1d561bf602 Mon Sep 17 00:00:00 2001 From: semarie Date: Wed, 20 Oct 2021 06:35:39 +0000 Subject: [PATCH] revert vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop (both kernel and userland bits) GENERIC + VFSLCKDEBUG is broken with it. --- share/man/man9/vnode.9 | 6 ++++-- sys/kern/vfs_subr.c | 7 +++++-- sys/kern/vfs_vops.c | 16 ++++++---------- sys/nfs/nfs_node.c | 5 ++++- sys/sys/vnode.h | 5 +++-- sys/ufs/ext2fs/ext2fs_subr.c | 5 ++++- sys/ufs/ffs/ffs_subr.c | 5 ++++- sys/ufs/ffs/ffs_vfsops.c | 5 ++++- sys/uvm/uvm_vnode.c | 4 ++-- usr.sbin/pstat/pstat.8 | 6 ++++-- usr.sbin/pstat/pstat.c | 4 +++- 11 files changed, 43 insertions(+), 25 deletions(-) diff --git a/share/man/man9/vnode.9 b/share/man/man9/vnode.9 index 80affa5459f..4f47d70eeeb 100644 --- a/share/man/man9/vnode.9 +++ b/share/man/man9/vnode.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: vnode.9,v 1.34 2021/10/19 14:50:05 semarie Exp $ +.\" $OpenBSD: vnode.9,v 1.35 2021/10/20 06:35:39 semarie Exp $ .\" .\" Copyright (c) 2001 Constantine Sapuntzakis .\" All rights reserved. @@ -23,7 +23,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: October 19 2021 $ +.Dd $Mdocdate: October 20 2021 $ .Dt VNODE 9 .Os .Sh NAME @@ -303,6 +303,8 @@ This vnode is locked to change its underlying type. A process is waiting for this vnode. .It Dv VALIASED This vnode has an alias. +.It Dv VLOCKSWORK +This vnode's underlying file system supports locking discipline. .El .Pp The diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index f807760ea9d..794a4f2cf03 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.307 2021/10/19 06:26:08 semarie Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.308 2021/10/20 06:35:39 semarie Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1075,6 +1075,9 @@ vclean(struct vnode *vp, int flags, struct proc *p) vp->v_op = &dead_vops; VN_KNOTE(vp, NOTE_REVOKE); vp->v_tag = VT_NON; +#ifdef VFSLCKDEBUG + vp->v_flag &= ~VLOCKSWORK; +#endif mtx_enter(&vnode_mtx); vp->v_lflag &= ~VXLOCK; if (vp->v_lflag & VXWANT) { @@ -1927,7 +1930,7 @@ vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, struct proc *p, int s, error; #ifdef VFSLCKDEBUG - if ((vp->v_op->vop_islocked != nullop) && !VOP_ISLOCKED(vp)) + if ((vp->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) panic("%s: vp isn't locked, vp %p", __func__, vp); #endif diff --git a/sys/kern/vfs_vops.c b/sys/kern/vfs_vops.c index c951368c158..c4562ecfaf5 100644 --- a/sys/kern/vfs_vops.c +++ b/sys/kern/vfs_vops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vops.c,v 1.32 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: vfs_vops.c,v 1.33 2021/10/20 06:35:39 semarie Exp $ */ /* * Copyright (c) 2010 Thordur I. Bjornsson * @@ -48,15 +48,11 @@ #include #ifdef VFSLCKDEBUG -#define ASSERT_VP_ISLOCKED(vp) do { \ - struct vnode *_vp = (vp); \ - int r; \ - if (_vp->v_op->vop_islocked == nullop) \ - break; \ - if ((r = VOP_ISLOCKED(_vp)) != LK_EXCLUSIVE) { \ - VOP_PRINT(_vp); \ - panic("%s: vp not locked, vp %p, %d", __func__, _vp, r);\ - } \ +#define ASSERT_VP_ISLOCKED(vp) do { \ + if (((vp)->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) { \ + VOP_PRINT(vp); \ + panic("vp not locked"); \ + } \ } while (0) #else #define ASSERT_VP_ISLOCKED(vp) /* nothing */ diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index 1069ad597da..958d64378ec 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_node.c,v 1.73 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: nfs_node.c,v 1.74 2021/10/20 06:35:39 semarie Exp $ */ /* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */ /* @@ -133,6 +133,9 @@ loop: } vp = nvp; +#ifdef VFSLCKDEBUG + vp->v_flag |= VLOCKSWORK; +#endif rrw_init_flags(&np->n_lock, "nfsnode", RWL_DUPOK | RWL_IS_VNODE); vp->v_data = np; /* we now have an nfsnode on this vnode */ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index b46719db71c..f318b77cc7c 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.161 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: vnode.h,v 1.162 2021/10/20 06:35:39 semarie Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -146,7 +146,8 @@ struct vnode { #define VCLONED 0x0400 /* vnode was cloned */ #define VALIASED 0x0800 /* vnode has an alias */ #define VLARVAL 0x1000 /* vnode data not yet set up by higher level */ -#define VCLONE 0x4000 /* vnode is a clone */ +#define VLOCKSWORK 0x4000 /* FS supports locking discipline */ +#define VCLONE 0x8000 /* vnode is a clone */ /* * (v_bioflag) Flags that may be manipulated by interrupt handlers diff --git a/sys/ufs/ext2fs/ext2fs_subr.c b/sys/ufs/ext2fs/ext2fs_subr.c index b0fb0323818..b03939be476 100644 --- a/sys/ufs/ext2fs/ext2fs_subr.c +++ b/sys/ufs/ext2fs/ext2fs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_subr.c,v 1.36 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: ext2fs_subr.c,v 1.37 2021/10/20 06:35:39 semarie Exp $ */ /* $NetBSD: ext2fs_subr.c,v 1.1 1997/06/11 09:34:03 bouyer Exp $ */ /* @@ -170,6 +170,9 @@ ext2fs_vinit(struct mount *mp, struct vnode **vpp) nvp->v_data = vp->v_data; vp->v_data = NULL; vp->v_op = &spec_vops; +#ifdef VFSLCKDEBUG + vp->v_flag &= ~VLOCKSWORK; +#endif vrele(vp); vgone(vp); /* Reinitialize aliased vnode. */ diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 7cc6a54a8d9..64d353860a3 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_subr.c,v 1.33 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.34 2021/10/20 06:35:39 semarie Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -272,6 +272,9 @@ ffs_vinit(struct mount *mntp, struct vnode **vpp) nvp->v_data = vp->v_data; vp->v_data = NULL; vp->v_op = &spec_vops; +#ifdef VFSLCKDEBUG + vp->v_flag &= ~VLOCKSWORK; +#endif vrele(vp); vgone(vp); /* diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 0b40150c13a..b513a271877 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.191 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.192 2021/10/20 06:35:39 semarie Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1324,6 +1324,9 @@ retry: return (error); } +#ifdef VFSLCKDEBUG + vp->v_flag |= VLOCKSWORK; +#endif ip = pool_get(&ffs_ino_pool, PR_WAITOK|PR_ZERO); rrw_init_flags(&ip->i_lock, "inode", RWL_DUPOK | RWL_IS_VNODE); ip->i_ump = ump; diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c index b97edd59dad..7d5984403bf 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_vnode.c,v 1.117 2021/10/19 06:26:09 semarie Exp $ */ +/* $OpenBSD: uvm_vnode.c,v 1.118 2021/10/20 06:35:40 semarie Exp $ */ /* $NetBSD: uvm_vnode.c,v 1.36 2000/11/24 20:34:01 chs Exp $ */ /* @@ -1328,7 +1328,7 @@ uvm_vnp_uncache(struct vnode *vp) * carry over sanity check from old vnode pager: the vnode should * be VOP_LOCK'd, and we confirm it here. */ - if ((vp->v_op->vop_islocked != nullop) && !VOP_ISLOCKED(vp)) + if ((vp->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) panic("uvm_vnp_uncache: vnode not locked!"); #endif diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8 index 8f92bae3870..927dd0cd4d5 100644 --- a/usr.sbin/pstat/pstat.8 +++ b/usr.sbin/pstat/pstat.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pstat.8,v 1.59 2021/10/19 14:50:05 semarie Exp $ +.\" $OpenBSD: pstat.8,v 1.60 2021/10/20 06:35:40 semarie Exp $ .\" $NetBSD: pstat.8,v 1.9.4.1 1996/06/02 09:08:17 mrg Exp $ .\" .\" Copyright (c) 1980, 1991, 1993, 1994 @@ -30,7 +30,7 @@ .\" .\" from: @(#)pstat.8 8.4 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: October 19 2021 $ +.Dd $Mdocdate: October 20 2021 $ .Dt PSTAT 8 .Os .Sh NAME @@ -271,6 +271,8 @@ VBWAIT waiting for output to complete. VALIASED vnode has an alias. .It F VONFREELIST vnode is on a free list. +.It l +VLOCKSWORK FS supports locking discipline. .It s VONSYNCLIST vnode is on syncer worklist. .El diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index af732d407a5..14a779eb2ae 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pstat.c,v 1.125 2021/10/19 14:50:05 semarie Exp $ */ +/* $OpenBSD: pstat.c,v 1.126 2021/10/20 06:35:40 semarie Exp $ */ /* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */ /*- @@ -499,6 +499,8 @@ vnode_print(struct vnode *avnode, struct vnode *vp) *fp++ = 'A'; if (vp->v_bioflag & VBIOONFREELIST) *fp++ = 'F'; + if (flag & VLOCKSWORK) + *fp++ = 'l'; if (vp->v_bioflag & VBIOONSYNCLIST) *fp++ = 's'; if (fp == flags) -- 2.20.1