[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190410012247.GB2454@sol.localdomain>
Date: Tue, 9 Apr 2019 18:22:49 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: linux-fscrypt@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-f2fs-devel@...ts.sourceforge.net
Subject: Re: [PATCH] fscrypt: cache decrypted symlink target in ->i_link
On Wed, Apr 10, 2019 at 02:04:25AM +0100, Al Viro wrote:
> On Tue, Apr 09, 2019 at 05:45:54PM -0700, Eric Biggers wrote:
> > On Wed, Apr 10, 2019 at 01:33:46AM +0100, Al Viro wrote:
> > > On Tue, Apr 09, 2019 at 04:35:44PM -0700, Eric Biggers wrote:
> > > > From: Eric Biggers <ebiggers@...gle.com>
> > > >
> > > > Path lookups that traverse encrypted symlink(s) are very slow because
> > > > each encrypted symlink needs to be decrypted each time it's followed.
> > > >
> > > > Make encrypted symlinks faster by caching the decrypted symlink target
> > > > in ->i_link. The first call to ->get_link() sets it; later calls simply
> > > > return it. ->symlink() also sets it when the symlink is created.
> > > >
> > > > When the inode's ->i_crypt_info is freed, ->i_link is freed too.
> > > >
> > > > Note: RCU-delayed freeing of ->i_link is not yet implemented.
> > > > Therefore, for now even when ->i_link is set, path lookups must continue
> > > > to drop out of RCU-walk mode when following an encrypted symlink.
> > >
> > > And how the devil would they continue to do that, if I might ask?
> > > ->get_link() is *NOT* called if ->i_link is non-NULL, period.
> >
> > You're right, I didn't notice that ->get_link() isn't called when
> > ->i_link is non-NULL.
> >
> > But that being the case, what's the point of simple_get_link()?
>
> Non-NULL ->get_link() => DCACHE_SYMLINK_TYPE in ->d_flags =>
> d_is_symlink() true => step_into() progresses to pick_link().
>
> IOW, non-NULL ->get_link() is what tells you that we have
> a symlink there.
I think that's pretty unintuitive. The fact that multiple filesystems including
ext4 set ->i_link on fast symlinks, then set ->get_link() to a function that
returns ->i_link, made me assume that's the mechanism by which such symlink
targets are returned to the VFS. When in fact fs/namei.c just uses ->i_link,
and never calls ->get_link().
Is there any reason why d_flags_for_inode() doesn't check S_ISLNK() instead, and
then fs/namei.c would call ->get_link() if non-NULL, otherwise use ->i_link?
- Eric
Powered by blists - more mailing lists