better lookup for knfsd

Bill Hawes (
Tue, 18 Nov 1997 08:22:26 -0500

I've put together some new code that I hope will lay to rest the dentry
validation/lookup problems in knfsd. Following suggestions from people
on the list here, it implements a general dentry-from-inode lookup
function that should work for any unix-like filesystem.

The basic idea is that directory inodes know their parent inode number,
so if you have an inode and parent (directory) inode as the starting
point, you can use the readdir operation to get the name of the inode
and the next parent inode number. Repeated calls can then build the path
until inode #2 is reached, at which point you can get the root dentry
from the superblock. Lookup_dentry with the name relative to the root
dentry then gives the correct dentry.

The call to readdir has to be bootstrapped by using a dentry obtained
from d_alloc_root, but this shouldn't be a problem. Filesystems with
unix-like semantics will read the directory info from disk, and fs using
synthetic inode numbers will just return the same parent inode.

Since knfsd is now passing inode and parent inode numbers in the
filehandle, when the dentry validation fails I can just do a lookup to
find the dentry. For now I'm leaving the dentry cacheing code in place,
but it probably won't be needed after I implement a patch-up list to
save lookup information.

>From my description of operation here, does anyone know of an
NFS-exportable fs that _wouldn't_ work with this lookup scheme?