From df665abd347e2141f54fcbcb44092f21b232fd85 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Wed, 26 Aug 2020 21:49:43 +0000 Subject: [PATCH] Fix a "v_seqc_users == 0 not met" panic when VFS_STATFS() fails during mount. r363210 introduced v_seqc_users to the vnodes. This change requires a vn_seqc_write_end() to match the vn_seqc_write_begin() in vfs_cache_root_clear(). mjg@ provided this patch which seems to fix the panic. Tested for an NFS mount where the VFS_STATFS() call will fail. Submitted by: mjg Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D26160 --- sys/kern/vfs_mount.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 84d14fadae1d..d2cd104318eb 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -969,11 +969,14 @@ vfs_domount_first( if ((error = VFS_MOUNT(mp)) != 0 || (error1 = VFS_STATFS(mp, &mp->mnt_stat)) != 0 || (error1 = VFS_ROOT(mp, LK_EXCLUSIVE, &newdp)) != 0) { + rootvp = NULL; if (error1 != 0) { error = error1; rootvp = vfs_cache_root_clear(mp); - if (rootvp != NULL) + if (rootvp != NULL) { + vhold(rootvp); vrele(rootvp); + } if ((error1 = VFS_UNMOUNT(mp, 0)) != 0) printf("VFS_UNMOUNT returned %d\n", error1); } @@ -983,6 +986,10 @@ vfs_domount_first( VI_LOCK(vp); vp->v_iflag &= ~VI_MOUNT; VI_UNLOCK(vp); + if (rootvp != NULL) { + vn_seqc_write_end(rootvp); + vdrop(rootvp); + } vn_seqc_write_end(vp); vrele(vp); return (error);