From mpp@mpp.com  Fri Apr  7 07:09:44 1995
Received: from mpp.com (dialup-3-200.gw.umn.edu [134.84.101.200])
          by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id HAA07897
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 7 Apr 1995 07:09:38 -0700
Received: (from mpp@localhost) by mpp.com (8.6.11/8.6.9) id JAA00346; Fri, 7 Apr 1995 09:08:44 -0500
Message-Id: <199504071408.JAA00346@mpp.com>
Date: Fri, 7 Apr 1995 09:08:44 -0500
From: pritc003@maroon.tc.umn.edu
Reply-To: pritc003@maroon.tc.umn.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: msdosfs: moving a file into another directory causes panic
X-Send-Pr-Version: 3.2

>Number:         303
>Category:       kern
>Synopsis:       msdosfs: moving a file into another directory causes panic
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr  7 07:10:02 1995
>Closed-Date:    Tue Apr 11 10:16:40 PDT 1995
>Last-Modified:
>Originator:     Mike Pritchard
>Release:        FreeBSD 2.1.0-Development i386
>Organization:
Mike Pritchard
>Environment:


>Description:

When using an MS-DOS file system, attempting to move a file into a
subdirectory will result in the following panic:

panic: msdosfs_hashins: already locked

This is because the code that does the rename already has the denode
locked when msdosfs_hashins() gets called, resulting in the panic
when the routine attempts to lock the denode again.

>How-To-Repeat:

Mount a MS-DOS file system, cd to the mount point and do the following:

# touch zzz
# mkdir xxx
# mv zzz xxx
Boom!

>Fix:
	
The attached patch changes the msdosfs_hashins() routine to not lock the
denode.  The caller is now resposible for obtaining the lock instead
of having msdosfs_hashins() do it for them.


*** /usr/src/sys/msdosfs/msdosfs_denode.c	Sun Mar 19 09:19:07 1995
--- msdosfs/msdosfs_denode.c	Fri Apr  7 08:49:57 1995
***************
*** 119,131 ****
  	dep->de_next = deq;
  	dep->de_prev = depp;
  	*depp = dep;
- 	if (dep->de_flag & DE_LOCKED)
- 		panic("msdosfs_hashins: already locked");
- 	if (curproc)
- 		dep->de_lockholder = curproc->p_pid;
- 	else
- 		dep->de_lockholder = -1;
- 	dep->de_flag |= DE_LOCKED;
  }
  
  static void
--- 119,124 ----
***************
*** 235,240 ****
--- 228,234 ----
  	 * can't be accessed until we've read it in and have done what we
  	 * need to it.
  	 */
+ 	VOP_LOCK(nvp);
  	msdosfs_hashins(ldep);
  
  	/*
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Tue Apr 11 10:16:40 PDT 1995 
State-Changed-Why:  
Patch applied in revision 1.11 1995/04/11 of msdosfs_denode.c. 
>Unformatted:



