From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 2 23:34:21 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB935106564A for ; Sat, 2 Jun 2012 23:34:21 +0000 (UTC) (envelope-from bjk@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 793B38FC0A for ; Sat, 2 Jun 2012 23:34:21 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q52NYLto001916 for ; Sat, 2 Jun 2012 23:34:21 GMT (envelope-from bjk@freebsd.org) Received: from localhost (bjk@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) with ESMTP id q52NYLe8001913 for ; Sat, 2 Jun 2012 23:34:21 GMT (envelope-from bjk@freebsd.org) X-Authentication-Warning: freefall.freebsd.org: bjk owned process doing -bs Date: Sat, 2 Jun 2012 23:34:21 +0000 (UTC) From: Benjamin Kaduk To: freebsd-hackers@freebsd.org Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Subject: namecache documentation and locking X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jun 2012 23:34:21 -0000 Hi all, My colleague recently pointed out to me that I was calling vgone() when I probably wanted to be using cache_purge() (as is done for implementations of this OS-specific function in other BSDs [1]). This caused me to take a look at the namecache functions and find not very much documentation of their use. I see that NetBSD has had a namecache.9 man page since 2001 [2], and their actual code shares its origin from 4.2 BSD with ours ... but our vfs_cache.c is at (CVS) revision 1.181 versus NetBSD's 1.88, and there are at least superficial differences between the two. Is there a summary of the design/implementation somewhere that I could use as a reference, or can someone send one here? I would like to come up with a namecache.9 for FreeBSD's implementation. The particular question which promped my investigation is for the locking around cache_purge(); I was not immediately able to tell from looking at other consumers whether the vnode lock needs to or should be held around such calls. Looking at the implementation of some of the other namecache functions makes it seem that the lock order is vnode lock then namecache lock, which would suggest that holding the vnode lock across cache_purge would be okay, but I would like some confirmation before I use and document it as such. Thanks, Ben Kaduk [1] http://git.openafs.org/?p=openafs.git;a=blob;f=src/afs/FBSD/osi_vm.c;h=072142d7991c0012339fe15eee7a474ac8db4a13;hb=HEAD#l115 http://git.openafs.org/?p=openafs.git;a=blob;f=src/afs/NBSD/osi_vm.c;h=5cc2beb3fa3772a25788205d1deb208a9113ef4e;hb=HEAD#l59 http://git.openafs.org/?p=openafs.git;a=blob;f=src/afs/OBSD/osi_vm.c;h=737b742310d3649ffbcea0f23f059ee761d638d2;hb=HEAD#l57 http://git.openafs.org/?p=openafs.git;a=blob;f=src/afs/DARWIN/osi_vm.c;h=805cb38f0c17c6c83d9abda649b946adddef1c98;hb=HEAD#l51 [2] http://netbsd.gw.com/cgi-bin/man-cgi?namecache++NetBSD-current http://cvsweb.netbsd.org/bsdweb.cgi/src/share/man/man9/namecache.9?only_with_tag=MAIN