Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/miscfs/specfs Put workaround fix for LOCKDEBUG panic men...



details:   https://anonhg.NetBSD.org/src/rev/583ef448bbbb
branches:  trunk
changeset: 747873:583ef448bbbb
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Oct 04 06:23:58 2009 +0000

description:
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.

diffstat:

 sys/miscfs/specfs/spec_vnops.c |  22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diffs (60 lines):

diff -r 2ea519c395f6 -r 583ef448bbbb sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Sun Oct 04 03:15:08 2009 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Sun Oct 04 06:23:58 2009 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index