In message <[EMAIL PROTECTED]>, Chris Wedgwood writes:
> On Tue, May 02, 2000 at 12:15:20AM -0400, Theodore Y. Ts'o wrote:
>
> Date: Mon, 1 May 2000 11:27:04 -0400 (EDT)
> From: Alexander Viro <[EMAIL PROTECTED]>
>
> Keep in mind that userland may need to be taught how to deal with getdents()
> returning duplicates - there is no reasonable way to serve that in
> the kernel.
>
> *BSD does this in libc, for the exactly same reason; there's no good way
> to do this in the kernel.
[...]
> I'm not sure how efficient and fast the code would be to make this
> work quickly, for large numbers of file systems it might prove
> horribly slow.
IMHO the BSD hacks to libc support unionfs were ugly. To write unionfs,
they used the existing nullfs "template", but then they had to modify the
VFS *and* other user-land stuff.
It depends what you mean by "reasonable way" and "good way". I've done it
in my prototype implementation of unionfs which uses fan-out stackable f/s:
(1) you read directory 1, and store the names you see in a hash table.
(2) as you read each entry from subsequent directories, you check if it's in
the hash table. If it is, skip it; if it's not, add it to the getdents
output buf, and add the entry to the hash-table.
This was a simple design and easy to implement. Yes it added overhead to
readdir(2) but not as much as you'd think. It was certainly not "horribly
slow", nor did it chew up lots of ram. I tried it on several directories
with several dozen entries each (i.e., typical directory sizes), not on
directories with thousands or more entries.
I think that if we're adding directory unification features into the linux
kernel, then we should add unique-fication of names as well to the kernel.
One possible way would be to take advantage of the fact that most
readdir()'s are followed by lstat()s of each entry (hence NFSv3's
READDIRPLUS): so when you do a readdir, maybe it's best to pre-create a
mini-dentry for each such entry, in anticipation of its probable use. The
advantage there is that the dentry already has the name, and we already have
code to do dentry lookups based on their name.
> --cw
Erez.