Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/namei.c: Remove unlikely of status being -ECHILD in lookup_fast()

Running my yearly branch profiling code, it detected a 100% wrong branch
condition in name.c for lookup_fast(). The code in question has:

status = d_revalidate(dentry, nd->flags);
if (likely(status > 0))
return dentry;
if (unlazy_child(nd, dentry, seq))
return ERR_PTR(-ECHILD);
if (unlikely(status == -ECHILD))
/* we'd been told to redo it in non-rcu mode */
status = d_revalidate(dentry, nd->flags);

If the status of the d_revalidate() is greater than zero, then the function
finishes. Otherwise, if it is an "unlazy_child" it returns with -ECHILD.
After the above two checks, the status is compared to -ECHILD, as that is
what is returned if the original d_revalidate() needed to be done in a
non-rcu mode.

Especially this path is called in a condition of:

if (nd->flags & LOOKUP_RCU) {

And most of the d_revalidate() functions have:

if (flags & LOOKUP_RCU)
return -ECHILD;

It appears that that is the only case that this if statement is triggered
on two of my machines, running in production.

As it is dependent on what filesystem mix is configured in the running
kernel, simply remove the unlikely() from the if statement.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Steven Rostedt (VMware) and committed by
Al Viro
26ddb45e 1e8f44f1

+1 -1
+1 -1
fs/namei.c
··· 1495 1495 return dentry; 1496 1496 if (unlazy_child(nd, dentry, seq)) 1497 1497 return ERR_PTR(-ECHILD); 1498 - if (unlikely(status == -ECHILD)) 1498 + if (status == -ECHILD) 1499 1499 /* we'd been told to redo it in non-rcu mode */ 1500 1500 status = d_revalidate(dentry, nd->flags); 1501 1501 } else {