Re: Open by inode? (was Re: knfsd)

Magnus Ahltorp (map@stacken.kth.se)
05 Jan 1999 04:10:11 +0100


> It is an layering violation.
>
> In 2.2 all VFS functions work on a dcache entry which refers to a filename,
> not an inode. To open by inode you have to play very dirty tricks: you would
> have to generate a dummy name and insert it into the dcache, but not write
> it to the physical filesystem[1].

In arla (a free AFS implementation), we manage a lot of files in a
cache directory. If normal lookups are used, this is very slow, since
lots of files lie in the same directory. This is speeded up somewhat
by the directory cache, but this is not very effective if the file is
not used for long and then suddenly used. The typical scenario is that
a lot of cache files are precreated (creation is slow, better not do
it real-time), and then they lie dormant until they are needed.

What our code does is that it fetches a handle for the file (by a
syscall that is implemented by the kernel module) and stores it. When
the cache file is needed, it makes a syscall again, now asking the
kernel to open the file. It gets a file descriptor, which can be used
as any file descriptor returned from a "normal" open. This is also
used in our AFS server implementation, in pretty much the same way.

> Also some filesystems don't have fixed inodes.

The file handle syscall is never needed in the arla code (in fact,
only the Linux, FreeBSD, NetBSD, OpenBSD, Digital Unix and Solaris
implementations support this), and if they are not found (determined
runtime), normal open calls are made. This way, it is only used for
speedups. Believe me, these things are useful.

/Magnus
map@stacken.kth.se

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/