From nobody@FreeBSD.org  Thu Sep 30 11:56:19 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3E09B106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 30 Sep 2010 11:56:19 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 2DC778FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 30 Sep 2010 11:56:19 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8UBuIMC016755
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 30 Sep 2010 11:56:18 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o8UBuIGl016726;
	Thu, 30 Sep 2010 11:56:18 GMT
	(envelope-from nobody)
Message-Id: <201009301156.o8UBuIGl016726@www.freebsd.org>
Date: Thu, 30 Sep 2010 11:56:18 GMT
From: "Oleg A. Mamontov" <oleg@mamontov.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: vnodes leakage during zfs unmount
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         151111
>Category:       kern
>Synopsis:       [zfs] vnodes leakage during zfs unmount
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    avg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 30 12:00:15 UTC 2010
>Closed-Date:    Mon Jan 21 15:45:41 UTC 2013
>Last-Modified:  Mon Jan 21 15:45:41 UTC 2013
>Originator:     Oleg A. Mamontov
>Release:        8-STABLE
>Organization:
Rambler Internet Holding
>Environment:
FreeBSD store06.video.rambler.ru 8.0-20100505-SNAP FreeBSD 8.0-20100505-SNAP #0: Wed May  5 07:45:52 UTC 2010     root@nat-sl.rambler.ru:/usr/obj/usr/src/sys/DEVEL  amd64
>Description:
During `zfs mount tank`, `zfs unmount tank` vfs.numvnodes is growing up to kern.maxvnodes.
>How-To-Repeat:
mdconfig -a -s128m -u0
zpool create tank md0
zfs umount tank
for i in `jot 1000`; do zfs mount tank; printf '%4d   ' $i; sysctl vfs.numvnodes; zfs umount tank; done
########################
 1   vfs.numvnodes: 708
 2   vfs.numvnodes: 709
 3   vfs.numvnodes: 710
 4   vfs.numvnodes: 711
 5   vfs.numvnodes: 712

..

995   vfs.numvnodes: 1702
996   vfs.numvnodes: 1703
997   vfs.numvnodes: 1704
998   vfs.numvnodes: 1705
999   vfs.numvnodes: 1706
1000   vfs.numvnodes: 1707

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Oct 15 15:39:38 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: "Oleg A. Mamontov" <oleg@mamontov.net>
Cc: kib@FreeBSD.org, pjd@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/151111: vnodes leakage during zfs unmount
Date: Mon, 18 Oct 2010 16:11:55 +0400

 On Thu, Sep 30, 2010 at 11:56:18AM +0000, Oleg A. Mamontov wrote:
 O> for i in `jot 1000`; do zfs mount tank; printf '%4d   ' $i; sysctl vfs.numvnodes; zfs umount tank; done
 O> ########################
 O>  1   vfs.numvnodes: 708
 O>  2   vfs.numvnodes: 709
 O>  3   vfs.numvnodes: 710
 O>  4   vfs.numvnodes: 711
 O>  5   vfs.numvnodes: 712
 O> 
 O> ..
 O> 
 O> 995   vfs.numvnodes: 1702
 O> 996   vfs.numvnodes: 1703
 O> 997   vfs.numvnodes: 1704
 O> 998   vfs.numvnodes: 1705
 O> 999   vfs.numvnodes: 1706
 O> 1000   vfs.numvnodes: 1707
 
 Here is my lame investigation of the problem. In the zfs_domount() function
 we've got the following code:
 
         /* Grab extra reference. */
         VERIFY(VFS_ROOT(vfsp, LK_EXCLUSIVE, &vp) == 0);
         VOP_UNLOCK(vp, 0);
 
 I suppose this code is expected to put an extra reference on the
 vfsp->mnt_vnodecovered vnode. Do I mistake here? If I don't then this is
 the source of leak.
 
 Debugging shows that zfs_zget(), called subsequently from zfs_root(),
 does not find an existing znode/vnode and allocates a new one, see at the
 end of zfs_zget() function. This vnode gots a reference and is forgotten.
 
 Sorry, if I am being mistaken :)
 
 -- 
 Totus tuus, Glebius.
Responsible-Changed-From-To: freebsd-fs->avg 
Responsible-Changed-By: avg 
Responsible-Changed-When: Mon Nov 26 10:59:47 UTC 2012 
Responsible-Changed-Why:  
I am interested in this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151111 
State-Changed-From-To: open->patched 
State-Changed-By: avg 
State-Changed-When: Sat Dec 1 18:17:22 UTC 2012 
State-Changed-Why:  
Should be fixed in head. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151111 
State-Changed-From-To: patched->closed 
State-Changed-By: avg 
State-Changed-When: Mon Jan 21 15:45:33 UTC 2013 
State-Changed-Why:  
Should be fixed now. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151111 
>Unformatted:
