Subject: Re: RFC: VOP_LOOKUP() speedup
To: None <>
From: Bill Studenmund <>
List: tech-kern
Date: 05/04/2004 12:13:28
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, May 04, 2004 at 01:07:10AM +0200, Reinoud Zandijk wrote:
> Dear folks,
> in my effort to get a full read/write UDF filingsystem on NetBSD, i=20
> stumbled on the following:
> 1) before a VOP_CREATE() / VOP_MKDIR() / ... is called, VOP_LOOKUP() is=
>    called first to check if the file opr directory name is allready prese=
>    or not.
> 2) VOP_LOOKLUP() uses the namecache to check if its there...
> 3) if the namecache fails, VOP_LOOKUP() needs to search the directory fro=
>    disc for the name. _hopefully_ its still in the cache....
> On CD/DVD media, swiching back and forth from writing to reading mode and
> completely plummets performance (say factor 40 to 100+) as it easily takes
> about a half a second to a second for a swich. The _last thing_ you want,
> is it to be told to read a piece of disc when you are writing data.
> To solve the most common case when writing files to disc, the copying of a
> directory tree, i would like to introduce a means to know if the answer of
> the namecache is authorative or not.
> My proposal for this is simple but elegant:
> 1) every vnode/inode describing a directory gets a `number of directory
> entries in cache' counter.
> 2) on addition or removal of an entry from the cache, this number is=20
> maintained. Also when an entry is purged from the LRU.
> 3) with this provision, ,VOP_LOOKUP() now can check the number of directo=
> entries in the directory with the `number of directory entries in cache'
> and see that the answer of the namecache is authorative if the two are the
> same.
> 4) if authorative it doesnt need to search the directory entry but signal=
> failure to find.
> Any comments would be much apreciated,

I object to this as an addition to the general case.

However, I think you can do everything you want in your own file system.

All you need is one extra bit per node. When you do a linear search of the=
dir, create vnodes and name cache entries for all files. Then flag the dir=
as all-present. Then in vop_revoke, in addition to blowing away cache=20
entries, clear the "All present" bit in the parent vnode.

One thing you might need is a way to search the name cache for all parent=
vnodes of a given vnode. Not sure if we have this interface. If we don't,=
it'd be a fine thing to add to the general code. Then on revoke, you clear=
the bit in all present parents.

Take care,


Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.3 (NetBSD)