NetBSD Problem Report #29775

From juan@xtraeme.nopcode.org  Wed Mar 23 17:41:06 2005
Return-Path: <juan@xtraeme.nopcode.org>
Received: from xtraeme.nopcode.org (91.Red-80-32-6.pooles.rima-tde.net [80.32.6.91])
	by narn.netbsd.org (Postfix) with ESMTP id B733A63B11A
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 23 Mar 2005 17:41:00 +0000 (UTC)
Message-Id: <20050323174049.56C115989@xtraeme.nopcode.org>
Date: Wed, 23 Mar 2005 18:40:49 +0100 (CET)
From: juan@xtraeme.nopcode.org
Reply-To: juan@xtraeme.nopcode.org
To: gnats-bugs@netbsd.org
Subject: Cannot use a vnode disk for domU
X-Send-Pr-Version: 3.95

>Number:         29775
>Category:       kern
>Synopsis:       Cannot use a vnode disk for domU
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bouyer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 23 17:42:00 +0000 2005
>Closed-Date:    Sun Apr 17 17:33:47 +0000 2005
>Last-Modified:  Sun Apr 17 17:33:47 +0000 2005
>Originator:     Juan RP
>Release:        NetBSD 3.99.1
>Organization:
>Environment:
System: NetBSD Mandylion 3.99.1 NetBSD 3.99.1 (GATEWAY_) #1: Wed Mar 23 06:34:57 CET 2005 juan@Nocturno:/home/juan/src-yamt-km/sys/arch/i386/compile/GATEWAY_ i386
Architecture: i386
Machine: i386
>Description:
	With -current Xen sources, I want to create a domU using
	a vnode disk in a file:

	$ dd if=/dev/zero of=mydisk.img bs=1k seek=20480k count=1
	$ vnconfig vnd0 mydisk.img

	$ grep vnd0 /etc/xen/netbsd
	disk = [ 'phy:/dev/cd0a,cd0a,r', 'phy:/dev/vnd0a,wd0d,w' ]
	$

	The system will crash.

>How-To-Repeat:
	See above.

>Fix:
	Please fixme!

>Release-Note:

>Audit-Trail:
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: tech-kern@NetBSD.org
Cc: port-xen-maintainer@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Wed, 23 Mar 2005 22:12:45 +0100

 [ moving to tech-kern ]

 On Wed, Mar 23, 2005 at 05:42:00PM +0000, juan@xtraeme.nopcode.org wrote:
 > >Description:
 > 	With -current Xen sources, I want to create a domU using
 > 	a vnode disk in a file:
 > 
 > 	$ dd if=/dev/zero of=mydisk.img bs=1k seek=20480k count=1
 > 	$ vnconfig vnd0 mydisk.img
 > 	
 > 	$ grep vnd0 /etc/xen/netbsd
 > 	disk = [ 'phy:/dev/cd0a,cd0a,r', 'phy:/dev/vnd0a,wd0d,w' ]
 > 	$
 > 
 > 	The system will crash.

 With:
 panic: lockmgr: no context
 It is in vndstrategy:
 		vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY | LK_CANRECURSE);

 This means that I/O on the vnd block device expect to be called from
 a process context, while the xbd backend calls it from interrupt context.
 And obvious way to fix this would be to add a kernel thread to the xbd backend
 to do this. But maybe this needs a closer look:
 - Can we safely say that vnd will always be called from process context ?
   What if we stack something else on vnd (fss or cgd for example) ?
 - Always taking a kernel thread in the xbd backend means an extra context
   switch, which we may want to avoid if possible. Is there a way to know if
   the underlying device can handle interrupt context or not ?

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
To: tech-kern@NetBSD.org
Cc: port-xen-maintainer@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Thu, 24 Mar 2005 07:53:01 +0900

 > With:
 > panic: lockmgr: no context
 > It is in vndstrategy:
 > 		vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY | LK_CANRECURSE);
 > 
 > This means that I/O on the vnd block device expect to be called from
 > a process context, while the xbd backend calls it from interrupt context.

 do you have a backtrace?

 YAMAMOTO Takashi

From: Jason Thorpe <thorpej@shagadelic.org>
To: tech-kern@NetBSD.org
Cc: port-xen-maintainer@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Wed, 23 Mar 2005 16:52:53 -0800

 On Mar 23, 2005, at 1:12 PM, Manuel Bouyer wrote:

 > This means that I/O on the vnd block device expect to be called from
 > a process context, while the xbd backend calls it from interrupt  
 > context.
 > And obvious way to fix this would be to add a kernel thread to the  
 > xbd backend
 > to do this. But maybe this needs a closer look:

 This is really a known problem.  The vnd driver needs to be rewritten  
 badly.  It needs to queue up requests and defer everything to a  
 kthread that actually does the work.

 -- thorpej

Responsible-Changed-From-To: port-xen-maintainer->bouyer
Responsible-Changed-By: bouyer@netbsd.org
Responsible-Changed-When: Tue, 29 Mar 2005 20:29:49 +0000
Responsible-Changed-Why:
I have  a patch for this.


From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: port-xen-maintainer@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Wed, 30 Mar 2005 18:52:25 +0200

 On Wed, Mar 23, 2005 at 05:42:00PM +0000, juan@xtraeme.nopcode.org wrote:
 > >Description:
 > 	With -current Xen sources, I want to create a domU using
 > 	a vnode disk in a file:
 > 
 > 	$ dd if=/dev/zero of=mydisk.img bs=1k seek=20480k count=1
 > 	$ vnconfig vnd0 mydisk.img
 > 	
 > 	$ grep vnd0 /etc/xen/netbsd
 > 	disk = [ 'phy:/dev/cd0a,cd0a,r', 'phy:/dev/vnd0a,wd0d,w' ]
 > 	$
 > 
 > 	The system will crash.

 I reclassified this from port-xen to kern, as it's really a problem in the
 vnd driver.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: Juan RP <juan@xtraeme.nopcode.org>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Wed, 30 Mar 2005 18:54:31 +0200

 On Wed, 30 Mar 2005 18:52:25 +0200
 Manuel Bouyer <bouyer@antioche.eu.org> wrote:

 > On Wed, Mar 23, 2005 at 05:42:00PM +0000, juan@xtraeme.nopcode.org wrote:
 > > >Description:
 > > 	With -current Xen sources, I want to create a domU using
 > > 	a vnode disk in a file:
 > > 
 > > 	$ dd if=/dev/zero of=mydisk.img bs=1k seek=20480k count=1
 > > 	$ vnconfig vnd0 mydisk.img
 > > 	
 > > 	$ grep vnd0 /etc/xen/netbsd
 > > 	disk = [ 'phy:/dev/cd0a,cd0a,r', 'phy:/dev/vnd0a,wd0d,w' ]
 > > 	$
 > > 
 > > 	The system will crash.
 > 
 > I reclassified this from port-xen to kern, as it's really a problem in the
 > vnd driver.

 Okay, I tried your patch and it works fine, thanks.

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29775 CVS commit: src/sys/dev
Date: Wed, 30 Mar 2005 19:23:08 +0000 (UTC)

 Module Name:	src
 Committed By:	bouyer
 Date:		Wed Mar 30 19:23:08 UTC 2005

 Modified Files:
 	src/sys/dev: vnd.c vndvar.h

 Log Message:
 Make vnd do I/O to the underlying file from thread context. This
 allows the strategy routine to be called from interrupt context, fixes
 PR kern/29775 by Juan RP.
 Now that pool_get() is only called from thread context, change PR_NOWAIT to
 PR_WAITOK. Fix PR kern/26272 by Juergen Hannken-Illjes.
 OK'd by thorpej@


 To generate a diff of this commit:
 cvs rdiff -r1.111 -r1.112 src/sys/dev/vnd.c
 cvs rdiff -r1.13 -r1.14 src/sys/dev/vndvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
To: thorpej@shagadelic.org
Cc: tech-kern@NetBSD.org, port-xen-maintainer@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Thu, 31 Mar 2005 08:10:04 +0900

 hi,

 > > This means that I/O on the vnd block device expect to be called from
 > > a process context, while the xbd backend calls it from interrupt  
 > > context.
 > > And obvious way to fix this would be to add a kernel thread to the  
 > > xbd backend
 > > to do this. But maybe this needs a closer look:
 > 
 > This is really a known problem.  The vnd driver needs to be rewritten  
 > badly.  It needs to queue up requests and defer everything to a  
 > kthread that actually does the work.
 > 
 > -- thorpej

 do you really think VOP_STRATEGY should be usable from interrupt context?

 YAMAMOTO Takashi

From: Jason Thorpe <thorpej@shagadelic.org>
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Cc: tech-kern@NetBSD.org, port-xen-maintainer@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: port-xen/29775: Cannot use a vnode disk for domU
Date: Wed, 30 Mar 2005 15:31:07 -0800

 On Mar 30, 2005, at 3:10 PM, YAMAMOTO Takashi wrote:

 > do you really think VOP_STRATEGY should be usable from interrupt  
 > context?

 DEV_STRATEGY(), sure.

 -- thorpej

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29775 CVS commit: [netbsd-3] src/sys/dev
Date: Sun,  3 Apr 2005 13:32:40 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Apr  3 13:32:40 UTC 2005

 Modified Files:
 	src/sys/dev [netbsd-3]: vndvar.h

 Log Message:
 Pull up revision 1.14 (requested by bouyer in ticket #85):
 Make vnd do I/O to the underlying file from thread context. This
 allows the strategy routine to be called from interrupt context, fixes
 PR kern/29775 by Juan RP.
 Now that pool_get() is only called from thread context, change PR_NOWAIT to
 PR_WAITOK. Fix PR kern/26272 by Juergen Hannken-Illjes.
 OK'd by thorpej@


 To generate a diff of this commit:
 cvs rdiff -r1.13 -r1.13.2.1 src/sys/dev/vndvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29775 CVS commit: [netbsd-3] src/sys/dev
Date: Sun,  3 Apr 2005 13:32:45 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Apr  3 13:32:45 UTC 2005

 Modified Files:
 	src/sys/dev [netbsd-3]: vnd.c

 Log Message:
 Pull up revision 1.112 (requested by bouyer in ticket #85):
 Make vnd do I/O to the underlying file from thread context. This
 allows the strategy routine to be called from interrupt context, fixes
 PR kern/29775 by Juan RP.
 Now that pool_get() is only called from thread context, change PR_NOWAIT to
 PR_WAITOK. Fix PR kern/26272 by Juergen Hannken-Illjes.
 OK'd by thorpej@


 To generate a diff of this commit:
 cvs rdiff -r1.111 -r1.111.10.1 src/sys/dev/vnd.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: bouyer@netbsd.org
State-Changed-When: Sun, 17 Apr 2005 17:33:47 +0000
State-Changed-Why:
Since I added a kernel thread to vnd(4), using a vnd as backing store for
domU xen should work fine. I also changed the xen backend driver to se
DEV_STRATEGY instead of VOP_STRATEGY as suggested by yamt@.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.