Subject: Re: RFC: VOP_LOOKUP() speedup
To: None <tech-kern@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 05/04/2004 12:13:28
--FL5UXtIhxfXey3p5
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,
>=20
> in my effort to get a full read/write UDF filingsystem on NetBSD, i=20
> stumbled on the following:
>=20
> 1) before a VOP_CREATE() / VOP_MKDIR() / ... is called, VOP_LOOKUP() is=
=20
> called first to check if the file opr directory name is allready prese=
nt=20
> 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=
m=20
> disc for the name. _hopefully_ its still in the cache....
>=20
> 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.
>=20
> 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.
>=20
> My proposal for this is simple but elegant:
>=20
> 1) every vnode/inode describing a directory gets a `number of directory
> entries in cache' counter.
>=20
> 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.
>=20
> 3) with this provision, ,VOP_LOOKUP() now can check the number of directo=
ry
> 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.
>=20
> 4) if authorative it doesnt need to search the directory entry but signal=
s=20
> failure to find.
>=20
> 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=
=20
dir, create vnodes and name cache entries for all files. Then flag the dir=
=20
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=
=20
vnodes of a given vnode. Not sure if we have this interface. If we don't,=
=20
it'd be a fine thing to add to the general code. Then on revoke, you clear=
=20
the bit in all present parents.
Take care,
Bill
--FL5UXtIhxfXey3p5
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFAl+tXWz+3JHUci9cRAsetAJwK+ETdPntBnXwfMq0BIKuLiparZQCfYHOj
Bvn/r4o1zp03cHi8rGOSSwA=
=9J5x
-----END PGP SIGNATURE-----
--FL5UXtIhxfXey3p5--