From pantzer@ludd.luth.se  Tue Oct  3 13:24:10 1995
Received: from stargate.orion.boden.se (root@stargate.orion.boden.se [193.45.246.235])
          by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id NAA20761
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 3 Oct 1995 13:24:05 -0700
Received: (from root@localhost) by stargate.orion.boden.se (8.6.11/8.6.9) id VAA28766; Tue, 3 Oct 1995 21:25:51 GMT
Message-Id: <199510032125.VAA28766@stargate.orion.boden.se>
Date: Tue, 3 Oct 1995 21:25:51 GMT
From: Mattias Pantzare <pantzer@ludd.luth.se>
Reply-To: pantzer@ludd.luth.se
To: FreeBSD-gnats-submit@freebsd.org
Subject: umount -f can`t umount a NFS filesystem in use
X-Send-Pr-Version: 3.2

>Number:         765
>Category:       kern
>Synopsis:       umount -f can`t umount a NFS filesystem in use
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct  3 13:30:02 PDT 1995
>Closed-Date:    Fri Jul 27 16:51:14 PDT 2001
>Last-Modified:  Fri Jul 27 16:53:03 PDT 2001
>Originator:     Mattias Pantzare
>Release:        FreeBSD 2.0-BUILT-19950628 i386
>Organization:
Orion
>Environment:

FreeBSD 2.1.0-950726-SNAP with a later kernel from STABLE 

>Description:

umount -f can`t umount a NFS filesystem if someone is using it.

>How-To-Repeat:

mount other_com:/usr /mnt
cd /mnt
umount -f /mnt

>Fix:

unknown
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->phk 
Responsible-Changed-By: scrappy 
Responsible-Changed-When: Sun May 26 23:17:20 PDT 1996 
Responsible-Changed-Why:  
I'm making a *very* weak assumption that this is a kernel nfs problem... 
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Mon Apr 13 01:31:06 PDT 1998 
State-Changed-Why:  
->suspended 
Responsible-Changed-From-To: phk->freebsd-bugs 
Responsible-Changed-By: phk 
Responsible-Changed-When: Mon Apr 13 01:31:27 PDT 1998 
Responsible-Changed-Why:  
->suspended 
State-Changed-From-To: suspended->feedback 
State-Changed-By: asmodai 
State-Changed-When: Sun Jun 11 01:48:50 PDT 2000 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=765 
Responsible-Changed-From-To: freebsd-bugs->asmodai 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Sun Jun 11 01:49:12 PDT 2000 
Responsible-Changed-Why:  
I'll monitor this PR. 

There were significant changes in NFS behaviour in the lastest FreeBSD 
versions.  I know that Matthew Dillon did a lot of kernel related 
things and I know Martin Blapp did a lot of mount_nfs related stuff. 

Could you try FreeBSD 4.0-RELEASE/STABLE and see if this problem still 
exists? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=765 

From: Mattias Pantzare <pantzer@ludd.luth.se>
To: freebsd-gnats-submit@FreeBSD.org
Cc: asmodai@FreeBSD.org
Subject: Re: kern/765: umount -f can`t umount a NFS filesystem in use
Date: Sun, 11 Jun 2000 12:13:39 +0200

 The problem exists on 4.0-STABLE from Jun 5 
 2000, and on -CURRENT from May 14 2000. It is only the mountpoint that is 
 affected, it works if a subdirectory is busy.
 
 
State-Changed-From-To: feedback->open 
State-Changed-By: johan 
State-Changed-When: Wed Aug 16 06:29:51 PDT 2000 
State-Changed-Why:  
feedback arrived. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=765 
State-Changed-From-To: open->closed 
State-Changed-By: alfred 
State-Changed-When: Tue Dec 12 04:48:16 PST 2000 
State-Changed-Why:  
user needs to upgrade and determine if the problem still exitst as 
well as provide a kenrel traceback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=765 
State-Changed-From-To: closed->open 
State-Changed-By: johan 
State-Changed-When: Mon Jan 22 05:03:35 PST 2001 
State-Changed-Why:  
This is still a problem in a 4.2-Stable from early january 2001. 

When asking the submitter to provide feedback, please use the 
feedback state instead of closing. 

This problem do not hang or panic the machine, the problem 
is that 'umount -f' simply does not work as is should. 



http://www.freebsd.org/cgi/query-pr.cgi?pr=765 

From: Ian Dowse <iedowse@maths.tcd.ie>
To: Mattias Pantzare <pantzer@ludd.luth.se>
Cc: FreeBSD-gnats-submit@freebsd.org, iedowse@maths.tcd.ie,
	dillon@freebsd.org
Subject: Re: kern/765: umount -f can`t umount a NFS filesystem in use
Date: Wed, 11 Apr 2001 22:21:02 +0100

 Hi Mattias,
 
 Could you try the following patch? The code in nfs_unmount() returns
 EBUSY if the reference count on the filesystem root vnode is greater
 than 2, but I can see absolutely no reason why it needs to do this.
 The call to vflush() should do everything that is required to clean
 up any vnodes that reference the mountpoint, and vflush() itself
 will return EBUSY if necessary (i.e if FORCECLOSE not specified).
 
 This bug explains the warning I've always seen on our diskless
 xterms here as they reboot:
 
 	syncing disks... 1 1 1
 	done
 	unmount of / failed (BUSY)
 	Uptime: 38m46s
 	Rebooting...
 
 I've done a small amount of testing here, and umount -f now works
 while there are references to the filesystem root. I also verified
 that a few simple commands such as "pwd" and "cd .." with a cwd
 within the unmounted filesystem don't do anything nasty.
 
 The code dates back to the initial import in '94, so there's every
 reason to suspect that it was there to deal with a problem that
 has been fixed long ago.
 
 Ian
 
 Index: nfs_vfsops.c
 ===================================================================
 RCS file: /FreeBSD/FreeBSD-CVS/src/sys/nfs/nfs_vfsops.c,v
 retrieving revision 1.93
 diff -u -r1.93 nfs_vfsops.c
 --- nfs_vfsops.c	2000/11/14 08:00:39	1.93
 +++ nfs_vfsops.c	2001/04/11 20:57:31
 @@ -969,7 +969,6 @@
  	nmp = VFSTONFS(mp);
  	/*
  	 * Goes something like this..
 -	 * - Check for activity on the root vnode (other than ourselves).
  	 * - Call vflush() to clear out vnodes for this file system,
  	 *   except for the root vnode.
  	 * - Decrement reference on the vnode representing remote root.
 @@ -985,10 +984,6 @@
  	if (error)
  		return(error);
  	vp = NFSTOV(np);
 -	if (vp->v_usecount > 2) {
 -		vput(vp);
 -		return (EBUSY);
 -	}
  
  	/*
  	 * Must handshake with nqnfs_clientd() if it is active.
 
 

From: Mattias Pantzare <pantzer@ludd.luth.se>
To: Ian Dowse <iedowse@maths.tcd.ie>
Cc: Mattias Pantzare <pantzer@ludd.luth.se>,
	FreeBSD-gnats-submit@freebsd.org, dillon@freebsd.org,
	pantzer@ludd.luth.se
Subject: Re: kern/765: umount -f can`t umount a NFS filesystem in use 
Date: Thu, 24 May 2001 22:25:49 +0200

 > 
 > Hi Mattias,
 > 
 > Could you try the following patch? The code in nfs_unmount() returns
 > EBUSY if the reference count on the filesystem root vnode is greater
 > than 2, but I can see absolutely no reason why it needs to do this.
 > The call to vflush() should do everything that is required to clean
 > up any vnodes that reference the mountpoint, and vflush() itself
 > will return EBUSY if necessary (i.e if FORCECLOSE not specified).
 > 
 > This bug explains the warning I've always seen on our diskless
 > xterms here as they reboot:
 > 
 > 	syncing disks... 1 1 1
 > 	done
 > 	unmount of / failed (BUSY)
 > 	Uptime: 38m46s
 > 	Rebooting...
 > 
 > I've done a small amount of testing here, and umount -f now works
 > while there are references to the filesystem root. I also verified
 > that a few simple commands such as "pwd" and "cd .." with a cwd
 > within the unmounted filesystem don't do anything nasty.
 > 
 > The code dates back to the initial import in '94, so there's every
 > reason to suspect that it was there to deal with a problem that
 > has been fixed long ago.
 
 You can't remove the check, then this works:
 
 mount foo:/bar /mnt
 cd /mnt
 umount /mnt
 
 That is not good.
 
 The solution is in revision 1.49 on NetBSD:
 
 RCS file: /ftp/cvs/cvsroot/syssrc/sys/nfs/nfs_vfsops.c,v
 retrieving revision 1.48
 retrieving revision 1.49
 diff -u -r1.48 -r1.49
 --- syssrc/sys/nfs/nfs_vfsops.c 1996/06/14 22:22:33     1.48
 +++ syssrc/sys/nfs/nfs_vfsops.c 1996/06/24 10:26:40     1.49
 @@ -1,4 +1,4 @@
 -/*     $NetBSD: nfs_vfsops.c,v 1.48 1996/06/14 22:22:33 cgd Exp $      */
 +/*     $NetBSD: nfs_vfsops.c,v 1.49 1996/06/24 10:26:40 pk Exp $       */
  
  /*
   * Copyright (c) 1989, 1993, 1995
 @@ -761,7 +761,7 @@
         if (error)
                 return(error);
         vp = NFSTOV(np);
 -       if (vp->v_usecount > 2) {
 +       if ((mntflags & MNT_FORCE) == 0 && vp->v_usecount > 2) {
                 vput(vp);
                 return (EBUSY);
         }
 

From: Ian Dowse <iedowse@maths.tcd.ie>
To: Mattias Pantzare <pantzer@ludd.luth.se>
Cc: Ian Dowse <iedowse@maths.tcd.ie>,
	FreeBSD-gnats-submit@freebsd.org, dillon@freebsd.org
Subject: Re: kern/765: umount -f can`t umount a NFS filesystem in use 
Date: Thu, 24 May 2001 22:19:39 +0100

 In message <200105242025.WAA24656@mother.ludd.luth.se>, Mattias Pantzare writes
 :
 >You can't remove the check, then this works:
 >
 >mount foo:/bar /mnt
 >cd /mnt
 >umount /mnt
 >
 >That is not good.
 
 Yes, I figured that out when I examined the code more closely (the
 example above is not a good one because of what checkdirs() does
 in -current, but you are quite correct otherwise). It turned out,
 however, that all the 9 filesystems in FreeBSD that make use of
 vflush's `skipvp' argument had this same problem, so I fixed this
 in a different way.
 
 See revision 1.312 of vfs_subr.c and associated filesystem changes
 for details. The filesystem now just tells vflush() how many extra
 references to expect on the root vnode, and vflush() does all the
 necessary FORCECLOSE checking; it then releases these extra references
 when successful.
 
 I'm not sure that I can MFC this to -stable, since it would break
 compatibility with existing filesystem modules, so maybe the NetBSD
 fix is more appropriate there.
 
 Ian
Responsible-Changed-From-To: asmodai->freebsd-bugs 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Wed Jun 20 06:15:05 PDT 2001 
Responsible-Changed-Why:  
I am definately the wrong person to keep this open. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=765 
State-Changed-From-To: open->closed 
State-Changed-By: iedowse 
State-Changed-When: Fri Jul 27 16:51:14 PDT 2001 
State-Changed-Why:  

This is finally fixed in both -current and -stable. See revision 
1.249.2.10 of sys/kern/vfs_subr.c and associated filesystem changes. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=765 
>Unformatted:
