Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Aug 2020 21:49:43 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364844 - head/sys/kern
Message-ID:  <202008262149.07QLnhMI097229@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Wed Aug 26 21:49:43 2020
New Revision: 364844
URL: https://svnweb.freebsd.org/changeset/base/364844

Log:
  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

Modified:
  head/sys/kern/vfs_mount.c

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Wed Aug 26 21:41:14 2020	(r364843)
+++ head/sys/kern/vfs_mount.c	Wed Aug 26 21:49:43 2020	(r364844)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008262149.07QLnhMI097229>