Module Name: src
Committed By: tsutsui
Date: Sun Oct 4 06:23:58 UTC 2009
Modified Files:
src/sys/miscfs/specfs: spec_vnops.c
Log Message:
Put workaround fix for LOCKDEBUG panic mentioned in PR kern/41078:
Don't try to load a driver module if the driver is already exist but just
not attached. [bc]dev_open() could return ENXIO even if the driver exists.
XXX: Maybe this should be handled by helper functions for
XXX: module_autoload() calls on demand.
To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/miscfs/specfs/spec_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.124 src/sys/miscfs/specfs/spec_vnops.c:1.125
--- src/sys/miscfs/specfs/spec_vnops.c:1.124 Sat Apr 25 15:06:32 2009
+++ src/sys/miscfs/specfs/spec_vnops.c Sun Oct 4 06:23:58 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: spec_vnops.c,v 1.124 2009/04/25 15:06:32 rmind Exp $ */
+/* $NetBSD: spec_vnops.c,v 1.125 2009/10/04 06:23:58 tsutsui Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.124 2009/04/25 15:06:32 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.125 2009/10/04 06:23:58 tsutsui Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -405,11 +405,20 @@
vp->v_vflag |= VV_ISTTY;
VOP_UNLOCK(vp, 0);
do {
+ const struct cdevsw *cdev;
+
gen = module_gen;
error = cdev_open(dev, ap->a_mode, S_IFCHR, l);
if (error != ENXIO)
break;
+ /* Check if we already have a valid driver */
+ mutex_enter(&device_lock);
+ cdev = cdevsw_lookup(dev);
+ mutex_exit(&device_lock);
+ if (cdev != NULL)
+ break;
+
/* Get device name from devsw_conv array */
if ((name = cdevsw_getname(major(dev))) == NULL)
break;
@@ -447,11 +456,20 @@
sd->sd_bdevvp = vp;
mutex_exit(&device_lock);
do {
+ const struct bdevsw *bdev;
+
gen = module_gen;
error = bdev_open(dev, ap->a_mode, S_IFBLK, l);
if (error != ENXIO)
break;
+ /* Check if we already have a valid driver */
+ mutex_enter(&device_lock);
+ bdev = bdevsw_lookup(dev);
+ mutex_exit(&device_lock);
+ if (bdev != NULL)
+ break;
+
/* Get device name from devsw_conv array */
if ((name = bdevsw_getname(major(dev))) == NULL)
break;