git: 9ff2fbdf2ded - main - tmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 15 Feb 2023 00:57:59 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=9ff2fbdf2ded59e276fdbf7ef7d18c726386b6fb
commit 9ff2fbdf2ded59e276fdbf7ef7d18c726386b6fb
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-02-13 23:23:24 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-02-15 00:57:40 +0000
tmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts
VOP_ISLOCKED() does not return bool, its only reliable use it to check
that the vnode is exclusively locked by the calling thread. Almost all
asserts of this form repeated auto-generated assertions from
vnode_if.src for VOPs, in the incorrect way.
In two places where the assertions would be meaningful, convert them to
ASSERT_VOP_LOCKED() statements.
Reviewed by: markj, mjg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38576
---
sys/fs/tmpfs/tmpfs_subr.c | 3 ++-
sys/fs/tmpfs/tmpfs_vnops.c | 24 ++++++++----------------
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index ccb9977c39eb..cfd4787fb712 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1110,7 +1110,8 @@ out:
*vpp = vp;
#ifdef INVARIANTS
- MPASS(*vpp != NULL && VOP_ISLOCKED(*vpp));
+ MPASS(*vpp != NULL);
+ ASSERT_VOP_LOCKED(*vpp, __func__);
TMPFS_NODE_LOCK(node);
MPASS(*vpp == node->tn_vnode);
TMPFS_NODE_UNLOCK(node);
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index b1d6bce6754f..ea09170661e7 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -218,11 +218,18 @@ tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
cache_enter(dvp, *vpp, cnp);
out:
+#ifdef INVARIANTS
/*
* If there were no errors, *vpp cannot be null and it must be
* locked.
*/
- MPASS(IFF(error == 0, *vpp != NULLVP && VOP_ISLOCKED(*vpp)));
+ if (error == 0) {
+ MPASS(*vpp != NULLVP);
+ ASSERT_VOP_LOCKED(*vpp, __func__);
+ } else {
+ MPASS(*vpp == NULL);
+ }
+#endif
return (error);
}
@@ -545,7 +552,6 @@ tmpfs_setattr(struct vop_setattr_args *v)
int error;
- MPASS(VOP_ISLOCKED(vp));
ASSERT_VOP_IN_SEQC(vp);
error = 0;
@@ -588,8 +594,6 @@ tmpfs_setattr(struct vop_setattr_args *v)
*/
tmpfs_update(vp);
- MPASS(VOP_ISLOCKED(vp));
-
return (error);
}
@@ -725,8 +729,6 @@ tmpfs_fsync(struct vop_fsync_args *v)
{
struct vnode *vp = v->a_vp;
- MPASS(VOP_ISLOCKED(vp));
-
tmpfs_check_mtime(vp);
tmpfs_update(vp);
@@ -745,9 +747,6 @@ tmpfs_remove(struct vop_remove_args *v)
struct tmpfs_node *dnode;
struct tmpfs_node *node;
- MPASS(VOP_ISLOCKED(dvp));
- MPASS(VOP_ISLOCKED(vp));
-
if (vp->v_type == VDIR) {
error = EISDIR;
goto out;
@@ -796,7 +795,6 @@ tmpfs_link(struct vop_link_args *v)
struct tmpfs_dirent *de;
struct tmpfs_node *node;
- MPASS(VOP_ISLOCKED(dvp));
MPASS(dvp != vp); /* XXX When can this be false? */
node = VP_TO_TMPFS_NODE(vp);
@@ -987,9 +985,6 @@ tmpfs_rename(struct vop_rename_args *v)
int error;
bool want_seqc_end;
- MPASS(VOP_ISLOCKED(tdvp));
- MPASS(IMPLIES(tvp != NULL, VOP_ISLOCKED(tvp)));
-
want_seqc_end = false;
/*
@@ -1323,9 +1318,6 @@ tmpfs_rmdir(struct vop_rmdir_args *v)
struct tmpfs_node *dnode;
struct tmpfs_node *node;
- MPASS(VOP_ISLOCKED(dvp));
- MPASS(VOP_ISLOCKED(vp));
-
tmp = VFS_TO_TMPFS(dvp->v_mount);
dnode = VP_TO_TMPFS_DIR(dvp);
node = VP_TO_TMPFS_DIR(vp);