Hi, all. A random thought just popped into my head which may be a
reasonable compromise for implementing direct mounts. To start, I'll
summarise my understand of why the in-kernel solution won't happen, as
a reality check. I'll then propose my solution.

Say you want a direct map in / and you have "data1" and "data2" as two
of the prospective mount points. The in-kernel solution would require
the automounter to get its grubby hands on each dentry lookup
operation in / which in turn implies that every dentry lookup has to
pass through the automounter.
Aside: perhaps this can be mitigated by attaching a dentry lookup
overriding method for / but then we still pay the penalty of an extra
test for every lookup, and for / we have an indirect function call.

It's been proposed that an alternative solution is to populate a
directory with a direct map with symlinks. Unfortunately, that looks a
little ugly, and <ls -lF /> would cause them all to be mounted, which
is not desirable, I presume.

OK, my idea (and remember: I did say it just popped into my head:-) is
to define a new inode type. Call it a "fake special" ("fakes" for
short). For a direct map, the automounter creates fakes in /, so you
would have: /data1 and /data2 being fakes. The filesystem (i.e. ext2)
would do the normal inode lookup thing as required, but either the FS
or the VFS would do something different if a fake is returned: the
device number or the name of the fake is passed to the automounter for
validation.

If the automounter approves, the inode is changed to a normal
directory, then the automounter is told to go ahead and do its
mounting, and finally the inode is returned.

If the automounter does no approve, the inode is discarded and the
dentry is dropped. The effect is that there is no dentry for that
name.

For directory lookups, fakes can be ignored, so <ls -lF /> won't show
/data1 and /data2. This could be done in the FS or in the VFS
<filldir> functions.

When a direct mount expires, the automounter signals the kernel to
change the mount point back to a fake and drop the dentry.

Finally, a method is required to remove fakes. Probably the simplest
would be to convert VFS fake inodes to directory inodes when the
automounter connection is not available, just like the case when the
automounter validates the fake, except that no mounting is performed.
You could then have the automounter breaking its connection to the
kernel and proceed to unlink(2) the fakes.

I readily admit this involves some hackery in the kernel and the
automounter, but it has the advantage of looking clean from userspace
and not throwing away speed in our fast VFS/dentry layer. The only
real overhead I see is the check for fakes after an inode lookup()
method is called. This seems pretty cheap to me. This scheme won't
slow down cached dentry lookups, which is the principal concern that
Linus has, if I'm not mistaken.

Anyway, this idea is somewhat half-baked. If there's some fundamental
flaw, I'm sure you won't be backwards about being forwards ;-)

                                Regards,

                                        Richard....

Reply via email to