git: 1e54362824f6 - main - vfs_op_exit(): assert that mnt_vfs_ops stays non-zero for unmount or suspend

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 29 Jun 2022 18:32:12 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=1e54362824f62a9d43585e94422d1d3d5f0268f9

commit 1e54362824f62a9d43585e94422d1d3d5f0268f9
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-06-20 15:54:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-06-29 18:31:47 +0000

    vfs_op_exit(): assert that mnt_vfs_ops stays non-zero for unmount or suspend
    
    Reviewed by:    mjg
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D35639
---
 sys/kern/vfs_mount.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 155e397b7f5e..73cc34da79ea 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1763,6 +1763,10 @@ vfs_op_exit_locked(struct mount *mp)
 	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));
 	mp->mnt_vfs_ops--;
 }