Re: [PATCH] fs: inline step_into() and walk_component()

From: Al Viro

Date: Wed Nov 19 2025 - 14:42:13 EST


On Wed, Nov 19, 2025 at 07:40:01PM +0100, Mateusz Guzik wrote:

> -static const char *pick_link(struct nameidata *nd, struct path *link,
> +static noinline const char *pick_link(struct nameidata *nd, struct path *link,
> struct inode *inode, int flags)
> {
> struct saved *last;
> const char *res;
> - int error = reserve_stack(nd, link);
> + int error;
> +
> + if (nd->flags & LOOKUP_RCU) {
> + /* make sure that d_is_symlink above matches inode */

Where would that "above" be? Have some pity on the readers...

> +static __always_inline const char *step_into(struct nameidata *nd, int flags,
> + struct dentry *dentry)
> +{
> + struct path path;
> + struct inode *inode;
> +
> + path.mnt = nd->path.mnt;
> + path.dentry = dentry;
> + if (!(nd->flags & LOOKUP_RCU))
> + goto slowpath;
> + if (unlikely(dentry->d_flags & DCACHE_MANAGED_DENTRY))
> + goto slowpath;
> + inode = path.dentry->d_inode;
> + if (unlikely(d_is_symlink(path.dentry)))
> + goto slowpath;
> + if (read_seqcount_retry(&path.dentry->d_seq, nd->next_seq))
> + return ERR_PTR(-ECHILD);
> + if (unlikely(!inode))
> + return ERR_PTR(-ENOENT);
> + nd->path = path;
> + nd->inode = inode;
> + nd->seq = nd->next_seq;
> + return NULL;
> +slowpath:
> + return step_into_slowpath(nd, flags, dentry);
> +}

Is there any point keeping that struct path here? Hell, what's wrong
with

static __always_inline const char *step_into(struct nameidata *nd, int flags,
struct dentry *dentry)
{
if (likely((nd->flags & LOOKUP_RCU) &&
!(dentry->d_flags & DCACHE_MANAGED_DENTRY) &&
!d_is_symlink(dentry))) {
// Simple case: no messing with refcounts and
// neither a symlink nor mountpoint.
struct inode *inode = dentry->d_inode;

if (read_seqcount_retry(&dentry->d_seq, nd->next_seq))
return ERR_PTR(-ECHILD);
if (unlikely(!inode))
return ERR_PTR(-ENOENT);
nd->path.dentry = dentry;
nd->inode = inode;
nd->seq = nd->next_seq;
return NULL;
}
return step_into_slowpath(nd, flags, dentry);
}

for that matter?