From curt@mofo.emergent.com  Mon Apr 24 21:51:12 1995
Received: from mofo.emergent.com (mofo.emergent.com [140.174.2.20])
          by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id VAA13102
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Apr 1995 21:51:10 -0700
Received: (from curt@localhost) by mofo.emergent.com (8.6.11/8.6.9) id VAA00498; Mon, 24 Apr 1995 21:51:09 -0700
Message-Id: <199504250451.VAA00498@mofo.emergent.com>
Date: Mon, 24 Apr 1995 21:51:09 -0700
From: Curt Mayer <curt@mofo.emergent.com>
Reply-To: curt@emergent.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: filesystem deadlock
X-Send-Pr-Version: 3.2

>Number:         360
>Category:       kern
>Synopsis:       filesystem deadlock trivial to produce
>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:   Mon Apr 24 22:00:01 1995
>Closed-Date:    Sun May 7 02:17:22 PDT 1995
>Last-Modified:
>Originator:     Curt Mayer
>Release:        FreeBSD 2.0.950412-SNAP i386
>Organization:
>Environment:

	CX486-DX2/80
	16M, wd and aic disks

>Description:

	the filesystem deadlocks when installing a file to itself.
	a ktrace shows a strange sequence:

   450 install  CALL  stat(0xefbfda0f,0xefbfd87c)
   450 install  NAMI  "/var/tmp/xx"
   450 install  RET   stat 0
   450 install  CALL  stat(0xefbfda07,0xefbfd7ec)
   450 install  NAMI  "termcap"
   450 install  RET   stat 0
   450 install  CALL  stat(0x4414,0xefbfd78c)
   450 install  NAMI  "/var/tmp/xx/termcap"
   450 install  RET   stat 0
   450 install  CALL  unlink(0x4414)
   450 install  NAMI  "/var/tmp/xx/termcap"
   450 install  RET   unlink 0
   450 install  CALL  open(0x4414,0x601,0x180)
   450 install  NAMI  "/var/tmp/xx/termcap"
   450 install  RET   open 3
   450 install  CALL  open(0xefbfda07,0,0)
   450 install  NAMI  "termcap"
   450 install  RET   open 4
   450 install  CALL  mmap(0,0x2c48e,0x1,0,0x4,0,0,0)
   450 install  RET   mmap 134807552/0x8090000
   450 install  CALL  write(0x3,0x8090000,0x2c48e)

	at this point, deadlock with ps -l reporting ufslk2
	
>How-To-Repeat:

	cd /tmp
	cp /etc/termcap .
	install -c -m 0644 termcap /tmp
	>lockup<

>Fix:
	don't install a file to itself.	
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: davidg 
State-Changed-When: Sun May 7 02:17:22 PDT 1995 
State-Changed-Why:  
The bug was caused by a deadlock between the VM system and the 
buffer I/O system trying to acquire the same lock. Fixed in 
rev 1.21/1.22 of ufs_lock.c. 
>Unformatted:



