VFS_MOUNT reverses sense of IMNT_MPSAFE test?

Konrad Schroder <[email protected]> Thu, 7 May 2026 07:41:54 -0700
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
While hunting down a deadlock involving mount_null, I ran into a 
reversed test for IMNT_MPSAFE in VFS_MOUNT().  I'm not sure if this is 
what's causing my problem, but it's almost certainly wrong.  Is there 
something I'm missing, or should I commit?

Index: sys/kern/vfs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v
retrieving revision 1.502
diff -U 11 -r1.502 vfs_subr.c
--- sys/kern/vfs_subr.c 7 Dec 2024 02:27:38 -0000       1.502
+++ sys/kern/vfs_subr.c 7 May 2026 14:38:15 -0000
@@ -1480,27 +1480,27 @@
         int mpsafe = mp->mnt_iflag & IMNT_MPSAFE;
         int error;

         /*
          * Note: The first time through, the vfs_mount function may set
          * IMNT_MPSAFE, so we have to cache it on entry in order to
          * avoid leaking a kernel lock.
          *
          * XXX Maybe the MPSAFE bit should be set in struct vfsops and
          * not in struct mount.
          */
-       if (mpsafe) {
+       if (!mpsafe) {
                 KERNEL_LOCK(1, NULL);
         }
         error = (*(mp->mnt_op->vfs_mount))(mp, a, b, c);
-       if (mpsafe) {
+       if (!mpsafe) {
                 KERNEL_UNLOCK_ONE(NULL);
         }

         return error;
  }

Thanks,

--
Konrad Schroder
[email protected]