svn commit: r247071 - head/sys/kern

Jamie Gritton jamie at FreeBSD.org
Thu Feb 21 02:41:38 UTC 2013


Author: jamie
Date: Thu Feb 21 02:41:37 2013
New Revision: 247071
URL: http://svnweb.freebsd.org/changeset/base/247071

Log:
  Don't worry if a module is already loaded when looking for a fstype to mount
  (possible in a race condition).
  
  Reviewed by:	kib
  MFC after:	1 week

Modified:
  head/sys/kern/vfs_init.c

Modified: head/sys/kern/vfs_init.c
==============================================================================
--- head/sys/kern/vfs_init.c	Thu Feb 21 02:40:20 2013	(r247070)
+++ head/sys/kern/vfs_init.c	Thu Feb 21 02:41:37 2013	(r247071)
@@ -122,7 +122,7 @@ struct vfsconf *
 vfs_byname_kld(const char *fstype, struct thread *td, int *error)
 {
 	struct vfsconf *vfsp;
-	int fileid;
+	int fileid, loaded;
 
 	vfsp = vfs_byname(fstype);
 	if (vfsp != NULL)
@@ -130,13 +130,17 @@ vfs_byname_kld(const char *fstype, struc
 
 	/* Try to load the respective module. */
 	*error = kern_kldload(td, fstype, &fileid);
+	loaded = (*error == 0);
+	if (*error == EEXIST)
+		*error = 0;
 	if (*error)
 		return (NULL);
 
 	/* Look up again to see if the VFS was loaded. */
 	vfsp = vfs_byname(fstype);
 	if (vfsp == NULL) {
-		(void)kern_kldunload(td, fileid, LINKER_UNLOAD_FORCE);
+		if (loaded)
+			(void)kern_kldunload(td, fileid, LINKER_UNLOAD_FORCE);
 		*error = ENODEV;
 		return (NULL);
 	}


More information about the svn-src-head mailing list