namecache documentation and locking
Benjamin Kaduk
bjk at freebsd.org
Sat Jun 2 23:34:21 UTC 2012
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
More information about the freebsd-hackers
mailing list