NetBSD Problem Report #40163

From www@NetBSD.org  Sat Dec 13 01:59:48 2008
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 4053163B89C
	for <gnats-bugs@gnats.netbsd.org>; Sat, 13 Dec 2008 01:59:48 +0000 (UTC)
Message-Id: <20081213015947.CC4AF63B121@narn.NetBSD.org>
Date: Sat, 13 Dec 2008 01:59:47 +0000 (UTC)
From: lloyd@must-have-coffee.gen.nz
Reply-To: lloyd@must-have-coffee.gen.nz
To: gnats-bugs@NetBSD.org
Subject: mv(1) cause WAPBL panic
X-Send-Pr-Version: www-1.0

>Number:         40163
>Category:       kern
>Synopsis:       mv(1) cause WAPBL panic
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    dholland
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 13 02:00:00 +0000 2008
>Closed-Date:    Mon Dec 15 05:31:18 +0000 2008
>Last-Modified:  Mon Dec 15 05:31:18 +0000 2008
>Originator:     Lloyd Parkes
>Release:        5.0_BETA
>Organization:
Must Have Coffee
>Environment:
NetBSD maro.must-have-coffee.gen.nz 5.0_BETA NetBSD 5.0_BETA (GENERIC) #0: Tue Dec  2 21:58:06 NZDT 2008  lloyd@maro.must-have-coffee.gen.nz:/vol/scratch/obj/amd64/sys/arch/amd64/compile/GENERIC amd64
>Description:
Typing "mv foo/foo ." causes a panic if the filesystem in question has logging enabled.


>How-To-Repeat:
Type "mv foo/foo ."
>Fix:
None.

>Release-Note:

>Audit-Trail:
From: Greg Oster <oster@cs.usask.ca>
To: lloyd@must-have-coffee.gen.nz
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/40163: mv(1) cause WAPBL panic 
Date: Fri, 12 Dec 2008 20:12:56 -0600

 lloyd@must-have-coffee.gen.nz writes:
 > >Number:         40163
 > >Category:       kern
 > >Synopsis:       mv(1) cause WAPBL panic
 > >Confidential:   no
 > >Severity:       critical
 > >Priority:       high
 > >Responsible:    kern-bug-people
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Sat Dec 13 02:00:00 +0000 2008
 > >Originator:     Lloyd Parkes
 > >Release:        5.0_BETA
 > >Organization:
 > Must Have Coffee
 > >Environment:
 > NetBSD maro.must-have-coffee.gen.nz 5.0_BETA NetBSD 5.0_BETA (GENERIC) #0: Tu
 > e Dec  2 21:58:06 NZDT 2008  lloyd@maro.must-have-coffee.gen.nz:/vol/scratch/
 > obj/amd64/sys/arch/amd64/compile/GENERIC amd64
 > >Description:
 > Typing "mv foo/foo ." causes a panic if the filesystem in question has loggin
 > g enabled.
 > 
 > 
 > >How-To-Repeat:
 > Type "mv foo/foo ."
 > >Fix:
 > None.

 Could you please provide the full trace of the panic?  It doesn't 
 appear like this problem is repeatable on any of the systems I have 
 access to.... 

 Thanks.

 Later...

 Greg Oster


From: "Jared D. McNeill" <jmcneill@invisible.ca>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/40163: mv(1) cause WAPBL panic
Date: Fri, 12 Dec 2008 21:20:02 -0500 (EST)

 On Sat, 13 Dec 2008, lloyd@must-have-coffee.gen.nz wrote:
 >> Description:
 > Typing "mv foo/foo ." causes a panic if the filesystem in question has logging enabled.

 I am able to reproduce this on 5.0 also, note that foo/foo must be a 
 directory and not a regular file. Here's the panic, hand-copied:

 Reader/writer lock error: rw_vector_enter: locking against myself

 lock address : 0x00000000ce211c30
 current cpu  :                  0
 current lwp  : 0x00000000cc5b65e0
 owner/count  : 0x00000000cc5b65e0 flags      : 0x0000000000000004

 panic: lock error
 fatal breakpoint trap in supervisor mode
 trap type 1 code 0 eip c053bc4c cs 8 eflags 246 cr2 bbb8cbe0 ilevel 0
 Stopped in pid 515.1 (mv) at    netbsd:breakpoint+0x4:  popl    %ebp
 db{0}> tr
 breakpoint(..)
 panic(..)
 lockdebug_abort(..)
 rw_abort(..)
 rw_vector_enter(..)
 vlockmgr(..)
 ffs_lock(..)
 VOP_LOCK(..)
 vn_lock(..)
 wapbl_ufs_rename(..)
 ufs_rename(..)
 VOP_RENAME(..)
 do_sys_rename(..)
 sys_rename(..)
 syscall(..)

From: Greg Oster <oster@cs.usask.ca>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/40163: mv(1) cause WAPBL panic 
Date: Fri, 12 Dec 2008 20:50:29 -0600

 "Jared D. McNeill" writes:
 > The following reply was made to PR kern/40163; it has been noted by GNATS.
 > 
 > From: "Jared D. McNeill" <jmcneill@invisible.ca>
 > To: gnats-bugs@NetBSD.org
 > Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.or
 > g
 > Subject: Re: kern/40163: mv(1) cause WAPBL panic
 > Date: Fri, 12 Dec 2008 21:20:02 -0500 (EST)
 > 
 >  On Sat, 13 Dec 2008, lloyd@must-have-coffee.gen.nz wrote:
 >  >> Description:
 >  > Typing "mv foo/foo ." causes a panic if the filesystem in question has log
 > ging enabled.
 >  
 >  I am able to reproduce this on 5.0 also, note that foo/foo must be a 
 >  directory and not a regular file.

 Ah! That is the key..

 db> tr
 breakpoint() at netbsd:breakpoint+0x5
 panic() at netbsd:panic+0x255
 lockdebug_abort() at netbsd:lockdebug_abort+0x42
 rw_vector_enter() at netbsd:rw_vector_enter+0x213
 vlockmgr() at netbsd:vlockmgr+0xf6
 VOP_LOCK() at netbsd:VOP_LOCK+0x28
 vn_lock() at netbsd:vn_lock+0xd9
 wapbl_ufs_rename() at netbsd:wapbl_ufs_rename+0x5c2
 ufs_rename() at netbsd:ufs_rename+0x39
 VOP_RENAME() at netbsd:VOP_RENAME+0x39
 do_sys_rename() at netbsd:do_sys_rename+0x3d6
 syscall() at netbsd:syscall+0xb4
 db> 


 (gdb) list *(wapbl_ufs_rename+0x5c2)
 0xffffffff802613b2 is in wapbl_ufs_rename (/u1/builds/build102/src/sys/ufs/ufs/ufs_wapbl.c:347).
 342              */
 343             fcnp->cn_flags &= ~(MODMASK | SAVESTART);
 344             fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
 345             if (newparent) {
 346                     vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 347                     if ((error = relookup(fdvp, &fvp, fcnp))) {
 348                             vput(fdvp);
 349                             vrele(ap->a_fvp);
 350                             goto out2;
 351                     }
 (gdb) 


 Later...

 Greg Oster


Responsible-Changed-From-To: kern-bug-people->dholland
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Sat, 13 Dec 2008 03:52:04 +0000
Responsible-Changed-Why:
rename.


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, lloyd@must-have-coffee.gen.nz
Subject: Re: kern/40163: mv(1) cause WAPBL panic
Date: Sat, 13 Dec 2008 03:52:09 +0000

 On Sat, Dec 13, 2008 at 02:55:02AM +0000, Greg Oster wrote:
  >>> Typing "mv foo/foo ." causes a panic if the filesystem in question has log
  >> ging enabled.
  >>  
  >>  I am able to reproduce this on 5.0 also, note that foo/foo must be a 
  >>  directory and not a regular file.
  >  
  >  Ah! That is the key..
  > [...]
  >  345             if (newparent) {
  >  346                     vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);

 Untested (I don't have any wapbl volumes on hand) patch:

 Index: ufs_wapbl.c
 ===================================================================
 RCS file: /cvsroot/src/sys/ufs/ufs/ufs_wapbl.c,v
 retrieving revision 1.3
 diff -u -p -r1.3 ufs_wapbl.c
 --- ufs_wapbl.c	8 Dec 2008 11:37:37 -0000	1.3
 +++ ufs_wapbl.c	13 Dec 2008 03:49:29 -0000
 @@ -343,6 +343,11 @@ wapbl_ufs_rename(void *v)
  	fcnp->cn_flags &= ~(MODMASK | SAVESTART);
  	fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
  	if (newparent) {
 +		/* Check for the rename("foo/foo", "foo") case. */
 +		if (fdvp == tvp) {
 +			error = doingdirectory ? ENOTEMPTY : ENOTDIR;
 +			goto out;
 +		}
  		vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
  		if ((error = relookup(fdvp, &fvp, fcnp))) {
  			vput(fdvp);


 Also, someone should squint at this to make sure "out" is the right
 error exit path here.

 -- 
 David A. Holland
 dholland@netbsd.org

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40163 CVS commit: src/sys/ufs/ufs
Date: Sat, 13 Dec 2008 04:45:28 +0000 (UTC)

 Module Name:	src
 Committed By:	dholland
 Date:		Sat Dec 13 04:45:28 UTC 2008

 Modified Files:
 	src/sys/ufs/ufs: ufs_wapbl.c

 Log Message:
 Don't deadlock on rename("foo/foo", "foo") in the case where foo/foo is a
 directory. This doesn't affect non-wapbl renames; it affects wapbl because
 one of the lock acquisitions was moved up past where this case otherwise
 fails.

 PR 40163 from Lloyd Parkes.


 To generate a diff of this commit:
 cvs rdiff -r1.3 -r1.4 src/sys/ufs/ufs/ufs_wapbl.c

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

From: Greg Oster <oster@cs.usask.ca>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/40163: mv(1) cause WAPBL panic 
Date: Fri, 12 Dec 2008 22:47:09 -0600

 David Holland writes:
 > The following reply was made to PR kern/40163; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: gnats-bugs@netbsd.org
 > Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org, lloyd@must-have-coffee.gen.nz
 > Subject: Re: kern/40163: mv(1) cause WAPBL panic
 > Date: Sat, 13 Dec 2008 03:52:09 +0000
 > 
 >  On Sat, Dec 13, 2008 at 02:55:02AM +0000, Greg Oster wrote:
 >   >>> Typing "mv foo/foo ." causes a panic if the filesystem in question has 
 > log
 >   >> ging enabled.
 >   >>  
 >   >>  I am able to reproduce this on 5.0 also, note that foo/foo must be a 
 >   >>  directory and not a regular file.
 >   >  
 >   >  Ah! That is the key..
 >   > [...]
 >   >  345             if (newparent) {
 >   >  346                     vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 >  
 >  Untested (I don't have any wapbl volumes on hand) patch:
 >  
 >  Index: ufs_wapbl.c
 >  ===================================================================
 >  RCS file: /cvsroot/src/sys/ufs/ufs/ufs_wapbl.c,v
 >  retrieving revision 1.3
 >  diff -u -p -r1.3 ufs_wapbl.c
 >  --- ufs_wapbl.c	8 Dec 2008 11:37:37 -0000	1.3
 >  +++ ufs_wapbl.c	13 Dec 2008 03:49:29 -0000
 >  @@ -343,6 +343,11 @@ wapbl_ufs_rename(void *v)
 >   	fcnp->cn_flags &= ~(MODMASK | SAVESTART);
 >   	fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
 >   	if (newparent) {
 >  +		/* Check for the rename("foo/foo", "foo") case. */
 >  +		if (fdvp == tvp) {
 >  +			error = doingdirectory ? ENOTEMPTY : ENOTDIR;
 >  +			goto out;
 >  +		}
 >   		vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 >   		if ((error = relookup(fdvp, &fvp, fcnp))) {
 >   			vput(fdvp);

 I now get:

 cow# mv foo/foo .
 mv: rename foo/foo to ./foo: Directory not empty

 as expected... 

 >  Also, someone should squint at this to make sure "out" is the right
 >  error exit path here.

 The light squinting I did made me think it's ok, but it should 
 probably be verified by better squinters...

 Later...

 Greg Oster


From: Lloyd Parkes <lloyd@must-have-coffee.gen.nz>
To: David Holland <dholland-bugs@netbsd.org>
Cc: gnats-bugs@netbsd.org,
 kern-bug-people@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: kern/40163: mv(1) cause WAPBL panic
Date: Sat, 13 Dec 2008 17:49:55 +1300

 On Dec 13, 2008, at 4:52 PM, David Holland wrote:
 > Untested (I don't have any wapbl volumes on hand) patch:

 Not untested anymore. The patch seems to have fixed the problem, and  
 I get the same error message from NetBSD as I do from other systems,  
 so the error path can't be too far wrong.

 Cheers,
 Lloyd

From: David Holland <dholland-bugs@netbsd.org>
To: Lloyd Parkes <lloyd@must-have-coffee.gen.nz>
Cc: dholland@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
	gnats-bugs@netbsd.org
Subject: Re: kern/40163: mv(1) cause WAPBL panic
Date: Sun, 14 Dec 2008 03:22:14 +0000

 On Sat, Dec 13, 2008 at 06:10:05AM +0000, Lloyd Parkes wrote:
  >> Untested (I don't have any wapbl volumes on hand) patch:
  >  
  >  Not untested anymore. The patch seems to have fixed the problem, and  
  >  I get the same error message from NetBSD as I do from other systems,  
  >  so the error path can't be too far wrong.

 Can you still unmount the fs afterwards? :-)

 (Anything wrong would almost certainly be vnode refcounting.)

 Did you (or anyone else listening) test it on 5.0? I need to file a
 pullup, and while there should be no reason for it to behave
 differently on 5.0, everything connected with rename is so bodgy that
 I'd like some positive confirmation. And I don't currently have a 5.0
 machine.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Greg Oster <oster@cs.usask.ca>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/40163: mv(1) cause WAPBL panic 
Date: Sat, 13 Dec 2008 21:40:37 -0600

 David Holland writes:
 > The following reply was made to PR kern/40163; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: Lloyd Parkes <lloyd@must-have-coffee.gen.nz>
 > Cc: dholland@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
 > 	gnats-bugs@netbsd.org
 > Subject: Re: kern/40163: mv(1) cause WAPBL panic
 > Date: Sun, 14 Dec 2008 03:22:14 +0000
 > 
 >  On Sat, Dec 13, 2008 at 06:10:05AM +0000, Lloyd Parkes wrote:
 >   >> Untested (I don't have any wapbl volumes on hand) patch:
 >   >  
 >   >  Not untested anymore. The patch seems to have fixed the problem, and  
 >   >  I get the same error message from NetBSD as I do from other systems,  
 >   >  so the error path can't be too far wrong.
 >  
 >  Can you still unmount the fs afterwards? :-)

 I can..

 >  (Anything wrong would almost certainly be vnode refcounting.)
 >  
 >  Did you (or anyone else listening) test it on 5.0? I need to file a
 >  pullup, and while there should be no reason for it to behave
 >  differently on 5.0, everything connected with rename is so bodgy that
 >  I'd like some positive confirmation. And I don't currently have a 5.0
 >  machine.

 I applied your changes to a 5.0_BETA tree and tested using that.
 I've also just run a fsck on the filesystem (it's been mounted and
 unmounted dozens of times since the first check) and it's showing 
 everything as clean.

 Later...

 Greg Oster


From: David Holland <dholland-bugs@netbsd.org>
To: Greg Oster <oster@cs.usask.ca>, gnats-bugs@netbsd.org
Cc: dholland@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
	lloyd@must-have-coffee.gen.nz
Subject: Re: kern/40163: mv(1) cause WAPBL panic
Date: Sun, 14 Dec 2008 04:06:09 +0000

 On Sun, Dec 14, 2008 at 03:45:01AM +0000, Greg Oster wrote:
  >  I applied your changes to a 5.0_BETA tree and tested using that.
  >  I've also just run a fsck on the filesystem (it's been mounted and
  >  unmounted dozens of times since the first check) and it's showing 
  >  everything as clean.

 Thanks.

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 14 Dec 2008 04:18:40 +0000
State-Changed-Why:
pullup-5 #187.


From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40163 CVS commit: [netbsd-5] src/sys/ufs/ufs
Date: Sun, 14 Dec 2008 11:56:04 +0000 (UTC)

 Module Name:	src
 Committed By:	bouyer
 Date:		Sun Dec 14 11:56:04 UTC 2008

 Modified Files:
 	src/sys/ufs/ufs [netbsd-5]: ufs_wapbl.c

 Log Message:
 Pull up following revision(s) (requested by dholland in ticket #187):
 	sys/ufs/ufs/ufs_wapbl.c: revision 1.4
 Don't deadlock on rename("foo/foo", "foo") in the case where foo/foo is a
 directory. This doesn't affect non-wapbl renames; it affects wapbl because
 one of the lock acquisitions was moved up past where this case otherwise
 fails.
 PR 40163 from Lloyd Parkes.


 To generate a diff of this commit:
 cvs rdiff -r1.2 -r1.2.8.1 src/sys/ufs/ufs/ufs_wapbl.c

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

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 15 Dec 2008 05:31:18 +0000
State-Changed-Why:
Fixed and pulled up; thanks for the report.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.