Re: [some sanity for a change] possible design issues for hybrids

Linus Torvalds
2004-08-27T04:42:26Z

On Fri, 27 Aug 2004 viro@parcelfarce.linux.theplanet.co.uk wrote:
>
> > Or do you have a cunning plan?
>
> a) set ->d_mount to 1 and set DCACHE_HYBRID at ->lookup() time
> b) in lookup_mnt():
> if (unlikely(dentry has DCACHE_HYBRID)) {
> if (linkely(dentry->d_mount == 1))
> goto New;
> }
> do the normal series of hash lookups
> if (likely(dentry doesn't have DCACHE_HYBRID))
> return;
> if (vfsmount is marked as hybrid && dentry == vfsmount->mnt_dentry)
> return;

Hmm.. Here we shouldn't have a vfsmount. If we have one, that means that
we found it in the hashes, and we should just have returned it
immediately (whether hybrid or not doesn't matter at that point).

Also, I don't see the magic with "dentry->d_mount == 1", since we may have
allowed the dentry to be mounted on for real at one of the places, without
losing it's "hydridity" (it's not a word, but dammit, it should be one)
for that.

Is that part just an optimization to avoid the hash lookups?

> New:
> allocate new vfsmount and mark it as hybrid
> attach it on top of our one and go there
>
> Does that qualify as cunning? With that approach we have nothing non-trivial
> to do at lookup time and lookup_mnt() will DTRT with minimal fuss.

Ok, I think it qualifies as cunning enough. It has the nice property of
not apparently needing any vfsmount-related code at all at lookup() time.
Which is a bonus.

> > Hmm. If you use the same dentry for mnt_root as for mnt_mountpoint, how do
> > you avoid the infinite loop in follow_mount? Another magic special case?
>
> See above. And yes, I'd love to get a separate dentry (and inode, while
> we are at it). But I don't see how to do that.
>
> One note: we might split lookup_mnt() in two functions - one for the
> middle of lookup, another for final (non-triggering) step.

Yes. We don't necessarily even want to trigger the special mountpoint case
at all if we don't need it - which normal usage probably wouldn't ever
trigger. So I agree 100% - that way I think you actually allocate the
vfsmount until somebody really starts doing the "new things". Was that
your plan?

Linus