NetBSD Problem Report #41078
From www@NetBSD.org Thu Mar 26 16:01:18 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 41ED763C133
for <gnats-bugs@gnats.netbsd.org>; Thu, 26 Mar 2009 16:01:18 +0000 (UTC)
Message-Id: <20090326160117.DB22063B8DE@www.NetBSD.org>
Date: Thu, 26 Mar 2009 16:01:17 +0000 (UTC)
From: Christoph_Egger@gmx.de
Reply-To: Christoph_Egger@gmx.de
To: gnats-bugs@NetBSD.org
Subject: mounting ext2fs via vnd causes LOCKDEBUG panic
X-Send-Pr-Version: www-1.0
>Number: 41078
>Category: kern
>Synopsis: mounting ext2fs via vnd causes LOCKDEBUG panic
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: haad
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 26 16:05:00 +0000 2009
>Closed-Date: Wed Dec 30 00:14:17 +0000 2009
>Last-Modified: Wed Dec 30 00:14:17 +0000 2009
>Originator: Christoph Egger
>Release: NetBSD/amd64 5.99.8
>Organization:
>Environment:
>Description:
Lockdebug panic happens when mounting ext2fs via vnd.
Reader / writer lock error: lockdebug_unlocked: no shared holds on this lock
lock address : 0xffff80004eea4d20 type : sleep/adaptive
initialized : 0xffffffff80711166
shared holds : 0 exclusive: 0
shares wanted: 0 exclusive: 0
current cpu : 0 last held: 0
current lwp : 0xffff80004f4d97e0 last held: 000000000000000000
last locked : 0xffffffff8070ea52 unlocked : 0xffffffff8070ead8
owner/count : 000000000000000000 flags : 0x0000000000000008
Turnstile chain at 0xffffffff80ce89e0.
=> No active turnstile for this lock.
panic: LOCKDEBUG
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff802388c5 cs 8 rflags 246 cr2 7f7ffd96ecb0 cpl 0
rsp ffff80004f4fe650
Stopped in pid 435.1 (mount_ext2fs) at netbsd:breakpoint+0x5: leave
db{0}> bt
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x289
lockdebug_abort1() at netbsd:lockdebug_abort1+0xd3
rw_exit() at netbsd:rw_exit+0xe9
vlockmgr() at netbsd:vlockmgr+0xd8
VOP_UNLOCK() at netbsd:VOP_UNLOCK+0x64
spec_open() at netbsd:spec_open+0x340
VOP_OPEN() at netbsd:VOP_OPEN+0x62
ext2fs_mount() at netbsd:ext2fs_mount+0x25a
VFS_MOUNT() at netbsd:VFS_MOUNT+0x44
do_sys_mount() at netbsd:do_sys_mount+0x62d
sys___mount50() at netbsd:sys___mount50+0x33
syscall() at netbsd:syscall+0xb6
>How-To-Repeat:
vndconfig -c vnd0 linux.img
mount -t ext2fs /dev/vnd0a /mnt
>Fix:
>Release-Note:
>Audit-Trail:
From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/41078 CVS commit: src/sys/ufs/ext2fs
Date: Fri, 11 Sep 2009 15:59:07 +0000
Module Name: src
Committed By: tsutsui
Date: Fri Sep 11 15:59:07 UTC 2009
Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c
Log Message:
Fix botch around argument check in ext2fs_mount(). Taken from ffs_vfsops.c.
Fixes LOCKDEBUG panic which is the same one mentioned in PR kern/41078
on trying to mount_ext2fs against a raw device, while that panic
seems to have another route cause around module_autoload() in
sys/miscfs/specfs/spec_vnops.c:spec_open().
To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/ext2fs/ext2fs_vfsops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
tsutsui@ceres.dti.ne.jp
Subject: Re: kern/41078: mounting ext2fs via vnd causes LOCKDEBUG panic
Date: Sat, 12 Sep 2009 02:01:44 +0900
> >Synopsis: mounting ext2fs via vnd causes LOCKDEBUG panic
:
> panic() at netbsd:panic+0x289
> lockdebug_abort1() at netbsd:lockdebug_abort1+0xd3
> rw_exit() at netbsd:rw_exit+0xe9
> vlockmgr() at netbsd:vlockmgr+0xd8
> VOP_UNLOCK() at netbsd:VOP_UNLOCK+0x64
> spec_open() at netbsd:spec_open+0x340
> VOP_OPEN() at netbsd:VOP_OPEN+0x62
> ext2fs_mount() at netbsd:ext2fs_mount+0x25a
> VFS_MOUNT() at netbsd:VFS_MOUNT+0x44
> do_sys_mount() at netbsd:do_sys_mount+0x62d
> sys___mount50() at netbsd:sys___mount50+0x33
> syscall() at netbsd:syscall+0xb6
This is not ext2fs or vnd(4) specific at all.
"mount_ffs /dev/wd7i /mnt" (where no wd7 disk)
on a LOCKDEBUG kernel is enough to cause this panic.
spec_open() in spec_vnops.c tries to call module_autoload()
if bdev_open() returns ENXIO (== device not configured),
but bdev_open() could return ENXIO even if the driver is
already loaded or builtin. (due to no device, no vnconfig(8) etc.)
The following patch seems to fix the panic and
vnd.kmod without builtin vnd still works properly,
but I wonder if it's worth to have some helper functions
in kern/subr_devsw.c for module_autoload() calls on demand.
---
Index: spec_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/miscfs/specfs/spec_vnops.c,v
retrieving revision 1.124
diff -u -r1.124 spec_vnops.c
--- spec_vnops.c 25 Apr 2009 15:06:32 -0000 1.124
+++ spec_vnops.c 11 Sep 2009 16:28:28 -0000
@@ -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;
---
Izumi Tsutsui
From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/41078 CVS commit: src/sys/miscfs/specfs
Date: Sun, 4 Oct 2009 06:23:58 +0000
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.
Responsible-Changed-From-To: kern-bug-people->haad
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Sun, 04 Oct 2009 15:33:41 +0900
Responsible-Changed-Why:
Assign to a person who implemented it.
From: "Christoph Egger" <Christoph_Egger@gmx.de>
To: gnats-bugs@NetBSD.org, tsutsui@NetBSD.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, kern-bug-people@netbsd.org, haad@NetBSD.org
Cc:
Subject: Re: kern/41078 (mounting ext2fs via vnd causes LOCKDEBUG panic)
Date: Mon, 05 Oct 2009 09:17:34 +0200
I retested and I can no longer reproduce the LOCKDEBUG panic.
I can mount ext2fs via vnd, some simple read/write accesses
with ls, cat and echo "bla" >>testfile
and unmounting the image work well.
Christoph
State-Changed-From-To: open->closed
State-Changed-By: haad@NetBSD.org
State-Changed-When: Wed, 30 Dec 2009 00:14:17 +0000
State-Changed-Why:
User can't reproduce this panic anymore and there were some fixes commited to this code some time ago.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.