Subject: RFC: VOP_LOOKUP() speedup
To: None <tech-kern@netbsd.org>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 05/04/2004 01:07:10
Dear folks,

in my effort to get a full read/write UDF filingsystem on NetBSD, i 
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 present 
   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 from 
   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 
maintained. Also when an entry is purged from the LRU.

3) with this provision, ,VOP_LOOKUP() now can check the number of directory
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 signals 
failure to find.

Any comments would be much apreciated,

Regards,
Reinoud