[Bug 273953] panic: vfs_remount_ro: mp is not busied

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 20 Sep 2023 03:45:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273953

--- Comment #1 from Konstantin Belousov <kib@FreeBSD.org> ---
This is cosmetic issue.
mnt_lockref should be asserted only after vfs_op_enter().
Patch below should be enough.

commit 5a85fa192ec81998b723361028da21c5bcb4e66f
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Wed Sep 20 06:42:31 2023 +0300

    vfs_remount_ro(): mnt_lockref should be only accessed after vfs_op_enter()

    PR:     273953

diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 45ab9cfc93cc..8364081585f8 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -3004,6 +3004,7 @@ vfs_remount_ro(struct mount *mp)
        struct vnode *vp_covered, *rootvp;
        int error;

+       vfs_op_enter(mp);
        KASSERT(mp->mnt_lockref > 0,
            ("vfs_remount_ro: mp %p is not busied", mp));
        KASSERT((mp->mnt_kern_flag & MNTK_UNMOUNT) == 0,
@@ -3012,17 +3013,19 @@ vfs_remount_ro(struct mount *mp)
        rootvp = NULL;
        vp_covered = mp->mnt_vnodecovered;
        error = vget(vp_covered, LK_EXCLUSIVE | LK_NOWAIT);
-       if (error != 0)
+       if (error != 0) {
+               vfs_op_exit(mp);
                return (error);
+       }
        VI_LOCK(vp_covered);
        if ((vp_covered->v_iflag & VI_MOUNT) != 0) {
                VI_UNLOCK(vp_covered);
                vput(vp_covered);
+               vfs_op_exit(mp);
                return (EBUSY);
        }
        vp_covered->v_iflag |= VI_MOUNT;
        VI_UNLOCK(vp_covered);
-       vfs_op_enter(mp);
        vn_seqc_write_begin(vp_covered);

        MNT_ILOCK(mp);

-- 
You are receiving this mail because:
You are on the CC list for the bug.