Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1492239
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 00/17] clean up readlinks |
| Date | 2016-09-28 04:20 +0200 |
| Message-ID | <smcDv-M0-3@gated-at.bofh.it> (permalink) |
| References | <sgF5v-7Bx-3@gated-at.bofh.it> <slR61-4eM-13@gated-at.bofh.it> <slX1L-7Mm-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Sep 27, 2016 at 11:38:33AM +0200, Miklos Szeredi wrote:
> > I have no problem with "let's get rid of generic_readlink" - not that
> > it bought us much, but sure, if you want to have decision made based upon
> > the combination of flags, let's do it. Just make NULL ->readlink + non-NULL
> > ->get_link() mean generic_readlink(), and we are done.
>
> Indeed. Except it really should be the other way round:
>
> - .get_link always returning the symlink body
> - only proc setting .jump_link to do its thing
> - RIP .readlink
> But that's an extra branch in the symlink following. I was worried
> about that and hence gone for the unification of the two.
Symlink traversal is a much hotter path than readlink() would ever be.
What's more, we do have jumps on normal symlink traversal - after all,
absolute symlinks are exactly that; it's "jump to root, then traverse
the following sequence of components". So having ->get_link() that
includes jumps is not that much of a stretch (note that it could both
jump and return a relative pathname to traverse after that; none of the
procfs-style ones do that, but there's no reason to prohibit that).
What I'd prefer is
* it's a symlink iff it has ->get_link()
* readlink(2) on a symlink is normally just using generic_readlink()
* that can be overridden by supplying a ->readlink() method.
* the first time readlink() hits a symlink it will check both
->get_link() and ->readlink() presence. Then, if it's a normal symlink,
the inode will get marked as such and all subsequent calls will just call
generic_readlink(). IOW, I would go for
if (unlikely(!marked)) {
if ->readlink is present
call ->readlink and return
if ->get_link is absent
fail
mark
}
call generic_readlink
> Yeah. We can do your above suggestion, it's certainly less brittle.
> But I think it's rather confusing, having ->get_link normally do
> readlink, except for proc, where readlink is done by ->readlink.
->readlink() is just an override for the cases when readlink(2) wants
to fake something (or, as in case of AFS ugliness, is used on non-symlinks).
The primary function of symlinks is traversal, not readlink...
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH 00/17] clean up readlinks Al Viro <viro@ZenIV.linux.org.uk> - 2016-09-27 05:20 +0200
Re: [PATCH 00/17] clean up readlinks Miklos Szeredi <mszeredi@redhat.com> - 2016-09-27 11:40 +0200
Re: [PATCH 00/17] clean up readlinks Al Viro <viro@ZenIV.linux.org.uk> - 2016-09-28 04:20 +0200
Re: [PATCH 00/17] clean up readlinks Miklos Szeredi <mszeredi@redhat.com> - 2016-09-28 16:50 +0200
csiph-web