From sclawson@cs.utah.edu  Fri Dec  4 13:54:52 1998
Received: from wrath.cs.utah.edu (wrath.cs.utah.edu [155.99.198.100])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA25277
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 4 Dec 1998 13:54:51 -0800 (PST)
          (envelope-from sclawson@cs.utah.edu)
Received: from moab.cs.utah.edu (moab.cs.utah.edu [155.99.212.88])
	by wrath.cs.utah.edu (8.8.8/8.8.8) with ESMTP id OAA18533
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 4 Dec 1998 14:54:27 -0700 (MST)
Received: (from sclawson@localhost)
	by moab.cs.utah.edu (8.9.1/8.9.1) id OAA10654;
	Fri, 4 Dec 1998 14:54:26 -0700 (MST)
	(envelope-from sclawson@cs.utah.edu)
Message-Id: <199812042154.OAA10654@moab.cs.utah.edu>
Date: Fri, 4 Dec 1998 14:54:26 -0700 (MST)
From: Stephen Clawson <sclawson@cs.utah.edu>
Reply-To: sclawson@cs.utah.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: missing wakeup in vfs_syscalls.c:dounmount
X-Send-Pr-Version: 3.2

>Number:         8965
>Category:       kern
>Synopsis:       missing wakeup in vfs_syscalls.c:dounmount
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec  4 14:00:00 PST 1998
>Closed-Date:    Sat Dec 12 13:02:45 PST 1998
>Last-Modified:  Sat Dec 12 13:07:14 PST 1998
>Originator:     Stephen Clawson
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
University of Utah
>Environment:

I'm running on a dual Pentium II/350 using the SMP kernel.

102 2:37pm ibapah: ~> uname -a
FreeBSD ibapah.cs.utah.edu 3.0-CURRENT FreeBSD 3.0-CURRENT #7: Fri Dec  4 14:03:40 MST 1998     sclawson@ibapah.cs.utah.edu:/usr/src/sys/compile/SMP  i386

>Description:

A process tries to unmount a filesystem (in my case this is amd and
it's an nfsv2 filesystem) and manages to get far enough into dounmount
that it sets the MNTK_UNMOUNT flag in the mountpoint's mnt_kern_flag
field.  Another process (in my case netscape) tries to stat a file
that's on that filesystem.  Netscape blocks in vfs_busy because
MNTK_UNMOUNT is set.  However when amd runs again it gets an error and
exits dounmount prematurely.  It clears the MNTK_UNMOUNT flag and
generally cleaning up, but dosen't call wakeup on the mountpoint,
causing netscape to hang since it's in an un-interruptable sleep. =(

Having a hung netscape isn't so bad until other things start hanging
because of the locks that it still holds. =)

>How-To-Repeat:

Leave a netscape running while a hyperactive amd tries to continually
unmount and remount the filesystem that your netscape cache is on.  At
least that's what does it for me.

The timing is weird on this one, since it'll only happen if you're
trying to stat a file on a filesystem that's being unmounted in which
both the VFS_SYNC and VFS_UNMOUNT calls fail in dounmount.

>Fix:
	
Add in the missing wakeup. =)

diff -c -r1.110 vfs_syscalls.c
*** vfs_syscalls.c      1998/11/03 14:29:09     1.110
--- vfs_syscalls.c      1998/12/04 21:03:25
***************
*** 494,499 ****
--- 494,501 ----
                mp->mnt_flag |= async_flag;
                lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK | LK_REENABLE,
                    &mountlist_slock, p);
+               if (mp->mnt_kern_flag & MNTK_MWAIT)
+                         wakeup((caddr_t)mp);
                return (error);
        }
        CIRCLEQ_REMOVE(&mountlist, mp, mnt_list);


>Release-Note:
>Audit-Trail:

From: "Kevin T. Van Maren" <vanmaren@marker.cs.utah.edu>
To: freebsd-gnats-submit@freebsd.org
Cc:  Subject: Re: kern/8965: missing wakeup in vfs_syscalls.c:dounmount
Date: Fri, 4 Dec 1998 18:20:23 -0700 (MST)

 Steve told me this was fixed in OpenBSD version 1.40, and is also
 fixed in NetBSD.
 
 Kevin
State-Changed-From-To: open->closed 
State-Changed-By: dillon 
State-Changed-When: Sat Dec 12 13:02:45 PST 1998 
State-Changed-Why:  
Commited indicated fix into FreeBSD-current, thanks! 
>Unformatted:
