aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/vfs_mount.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 73cc34da79ea..7d74ec8b0a9e 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -679,12 +679,10 @@ vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp, const char *fspath,
mp->mnt_nvnodelistsize = 0;
TAILQ_INIT(&mp->mnt_lazyvnodelist);
mp->mnt_lazyvnodelistsize = 0;
- if (mp->mnt_ref != 0 || mp->mnt_lockref != 0 ||
- mp->mnt_writeopcount != 0)
- panic("%s: non-zero counters on new mp %p\n", __func__, mp);
- if (mp->mnt_vfs_ops != 1)
- panic("%s: vfs_ops should be 1 but %d found\n", __func__,
- mp->mnt_vfs_ops);
+ MPPASS(mp->mnt_ref == 0 && mp->mnt_lockref == 0 &&
+ mp->mnt_writeopcount == 0, mp);
+ MPASSERT(mp->mnt_vfs_ops == 1, mp,
+ ("vfs_ops should be 1 but %d found", mp->mnt_vfs_ops));
(void) vfs_busy(mp, MBF_NOWAIT);
atomic_add_acq_int(&vfsp->vfc_refcount, 1);
mp->mnt_op = vfsp->vfc_vfsops;
@@ -717,8 +715,7 @@ void
vfs_mount_destroy(struct mount *mp)
{
- if (mp->mnt_vfs_ops == 0)
- panic("%s: entered with zero vfs_ops\n", __func__);
+ MPPASS(mp->mnt_vfs_ops != 0, mp);
vfs_assert_mount_counters(mp);
@@ -733,10 +730,8 @@ vfs_mount_destroy(struct mount *mp)
KASSERT(mp->mnt_ref == 0,
("%s: invalid refcount in the drain path @ %s:%d", __func__,
__FILE__, __LINE__));
- if (mp->mnt_writeopcount != 0)
- panic("vfs_mount_destroy: nonzero writeopcount");
- if (mp->mnt_secondary_writes != 0)
- panic("vfs_mount_destroy: nonzero secondary_writes");
+ MPPASS(mp->mnt_writeopcount == 0, mp);
+ MPPASS(mp->mnt_secondary_writes == 0, mp);
atomic_subtract_rel_int(&mp->mnt_vfc->vfc_refcount, 1);
if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) {
struct vnode *vp;
@@ -748,21 +743,16 @@ vfs_mount_destroy(struct mount *mp)
KASSERT(mp->mnt_upper_pending == 0, ("mnt_upper_pending"));
KASSERT(TAILQ_EMPTY(&mp->mnt_uppers), ("mnt_uppers"));
KASSERT(TAILQ_EMPTY(&mp->mnt_notify), ("mnt_notify"));
- if (mp->mnt_nvnodelistsize != 0)
- panic("vfs_mount_destroy: nonzero nvnodelistsize");
- if (mp->mnt_lazyvnodelistsize != 0)
- panic("vfs_mount_destroy: nonzero lazyvnodelistsize");
- if (mp->mnt_lockref != 0)
- panic("vfs_mount_destroy: nonzero lock refcount");
+ MPPASS(mp->mnt_nvnodelistsize == 0, mp);
+ MPPASS(mp->mnt_lazyvnodelistsize == 0, mp);
+ MPPASS(mp->mnt_lockref == 0, mp);
MNT_IUNLOCK(mp);
- if (mp->mnt_vfs_ops != 1)
- panic("%s: vfs_ops should be 1 but %d found\n", __func__,
- mp->mnt_vfs_ops);
+ MPASSERT(mp->mnt_vfs_ops == 1, mp,
+ ("vfs_ops should be 1 but %d found", mp->mnt_vfs_ops));
- if (mp->mnt_rootvnode != NULL)
- panic("%s: mount point still has a root vnode %p\n", __func__,
- mp->mnt_rootvnode);
+ MPASSERT(mp->mnt_rootvnode == NULL, mp,
+ ("mount point still has a root vnode %p", mp->mnt_rootvnode));
if (mp->mnt_vnodecovered != NULL)
vrele(mp->mnt_vnodecovered);
@@ -1747,9 +1737,10 @@ vfs_op_enter(struct mount *mp)
mp->mnt_writeopcount += mpcpu->mntp_writeopcount;
mpcpu->mntp_writeopcount = 0;
}
- if (mp->mnt_ref <= 0 || mp->mnt_lockref < 0 || mp->mnt_writeopcount < 0)
- panic("%s: invalid count(s) on mp %p: ref %d lockref %d writeopcount %d\n",
- __func__, mp, mp->mnt_ref, mp->mnt_lockref, mp->mnt_writeopcount);
+ MPASSERT(mp->mnt_ref > 0 && mp->mnt_lockref >= 0 &&
+ mp->mnt_writeopcount >= 0, mp,
+ ("invalid count(s): ref %d lockref %d writeopcount %d",
+ mp->mnt_ref, mp->mnt_lockref, mp->mnt_writeopcount));
MNT_IUNLOCK(mp);
vfs_assert_mount_counters(mp);
}
@@ -1760,13 +1751,11 @@ vfs_op_exit_locked(struct mount *mp)
mtx_assert(MNT_MTX(mp), MA_OWNED);
- if (mp->mnt_vfs_ops <= 0)
- panic("%s: invalid vfs_ops count %d for mp %p\n",
- __func__, mp->mnt_vfs_ops, mp);
- KASSERT(mp->mnt_vfs_ops > 1 ||
- (mp->mnt_kern_flag & (MNTK_UNMOUNT | MNTK_SUSPEND)) == 0,
- ("%s: vfs_ops too low (%d) for mp %p in unmount or suspend",
- __func__, mp->mnt_vfs_ops, mp));
+ MPASSERT(mp->mnt_vfs_ops > 0, mp,
+ ("invalid vfs_ops count %d", mp->mnt_vfs_ops));
+ MPASSERT(mp->mnt_vfs_ops > 1 ||
+ (mp->mnt_kern_flag & (MNTK_UNMOUNT | MNTK_SUSPEND)) == 0, mp,
+ ("vfs_ops too low %d in unmount or suspend", mp->mnt_vfs_ops));
mp->mnt_vfs_ops--;
}