From: semarie Date: Tue, 19 Oct 2021 06:26:08 +0000 (+0000) Subject: vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=10dc078528519b6d34f2083e65dda8cc55239771;p=openbsd vnode: remove VLOCKSWORK and check locking when vop_islocked != nullop This flag is currently used to mark or unmark a vnode to actively check vnode locking semantic (when compiled with VFSLCKDEBUG). Currently, VLOCKSWORK flag isn't properly set for several FS implementation which have full locking support. This commit enable proper checking for them too (cd9660, udf, fuse, msdosfs, tmpfs). Instead of using a particular flag, it directly check if v_op->vop_islocked is nullop or not to activate or not the vnode locking checks. ok mpi@ --- diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index c752dd99e9e..f807760ea9d 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.306 2021/08/31 15:31:28 claudio Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.307 2021/10/19 06:26:08 semarie Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1075,9 +1075,6 @@ 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) { @@ -1930,7 +1927,7 @@ vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, struct proc *p, int s, error; #ifdef VFSLCKDEBUG - if ((vp->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) + if ((vp->v_op->vop_islocked != nullop) && !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 caf2dc327bf..c951368c158 100644 --- a/sys/kern/vfs_vops.c +++ b/sys/kern/vfs_vops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vops.c,v 1.31 2021/10/04 08:11:02 claudio Exp $ */ +/* $OpenBSD: vfs_vops.c,v 1.32 2021/10/19 06:26:09 semarie Exp $ */ /* * Copyright (c) 2010 Thordur I. Bjornsson * @@ -48,11 +48,15 @@ #include #ifdef VFSLCKDEBUG -#define ASSERT_VP_ISLOCKED(vp) do { \ - if (((vp)->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) { \ - VOP_PRINT(vp); \ - panic("vp not locked"); \ - } \ +#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);\ + } \ } while (0) #else #define ASSERT_VP_ISLOCKED(vp) /* nothing */ diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index 5c98411501b..1069ad597da 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_node.c,v 1.72 2021/10/19 06:11:45 semarie Exp $ */ +/* $OpenBSD: nfs_node.c,v 1.73 2021/10/19 06:26:09 semarie Exp $ */ /* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */ /* @@ -133,9 +133,6 @@ 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 c72c0711476..b46719db71c 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.160 2021/10/15 06:30:06 semarie Exp $ */ +/* $OpenBSD: vnode.h,v 1.161 2021/10/19 06:26:09 semarie Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -146,8 +146,7 @@ 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 VLOCKSWORK 0x4000 /* FS supports locking discipline */ -#define VCLONE 0x8000 /* vnode is a clone */ +#define VCLONE 0x4000 /* 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 d859d216b40..b0fb0323818 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.35 2016/08/10 07:53:02 natano Exp $ */ +/* $OpenBSD: ext2fs_subr.c,v 1.36 2021/10/19 06:26:09 semarie Exp $ */ /* $NetBSD: ext2fs_subr.c,v 1.1 1997/06/11 09:34:03 bouyer Exp $ */ /* @@ -170,9 +170,6 @@ 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 2aedef06acf..7cc6a54a8d9 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.32 2016/08/10 11:33:01 natano Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.33 2021/10/19 06:26:09 semarie Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -272,9 +272,6 @@ 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 48303e6a811..0b40150c13a 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.190 2021/10/04 08:11:02 claudio Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.191 2021/10/19 06:26:09 semarie Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1324,9 +1324,6 @@ 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 5fc969c3ff7..b97edd59dad 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_vnode.c,v 1.116 2021/10/12 07:38:22 mpi Exp $ */ +/* $OpenBSD: uvm_vnode.c,v 1.117 2021/10/19 06:26:09 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_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) + if ((vp->v_op->vop_islocked != nullop) && !VOP_ISLOCKED(vp)) panic("uvm_vnp_uncache: vnode not locked!"); #endif