Skip to content

Commit

Permalink
tmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kostikbel committed Feb 15, 2023
1 parent 5942b4b commit 9ff2fbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
3 changes: 2 additions & 1 deletion sys/fs/tmpfs/tmpfs_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,8 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, int lkflag,
*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);
Expand Down
24 changes: 8 additions & 16 deletions sys/fs/tmpfs/tmpfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -545,7 +552,6 @@ tmpfs_setattr(struct vop_setattr_args *v)

int error;

MPASS(VOP_ISLOCKED(vp));
ASSERT_VOP_IN_SEQC(vp);

error = 0;
Expand Down Expand Up @@ -588,8 +594,6 @@ tmpfs_setattr(struct vop_setattr_args *v)
*/
tmpfs_update(vp);

MPASS(VOP_ISLOCKED(vp));

return (error);
}

Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9ff2fbd

Please sign in to comment.