Skip to content

Commit

Permalink
VFS: Combine inode checks with d_is_negative() and d_is_positive() in…
Browse files Browse the repository at this point in the history
… pathwalk

Where we have:

    	if (!dentry->d_inode || d_is_negative(dentry)) {

type constructions in pathwalk we should be able to eliminate the check of
d_inode and rely solely on the result of d_is_negative() or d_is_positive().

What we do have to take care to do is to read d_inode after calling a
d_is_xxx() typecheck function to get the barriering right.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
David Howells authored and Al Viro committed Apr 15, 2015
1 parent 88e7fbd commit 698934d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ static inline int walk_component(struct nameidata *nd, struct path *path,
inode = path->dentry->d_inode;
}
err = -ENOENT;
if (!inode || d_is_negative(path->dentry))
if (d_is_negative(path->dentry))
goto out_path_put;

if (should_follow_link(path->dentry, follow)) {
Expand Down Expand Up @@ -2310,7 +2310,7 @@ mountpoint_last(struct nameidata *nd, struct path *path)
mutex_unlock(&dir->d_inode->i_mutex);

done:
if (!dentry->d_inode || d_is_negative(dentry)) {
if (d_is_negative(dentry)) {
error = -ENOENT;
dput(dentry);
goto out;
Expand Down Expand Up @@ -3038,7 +3038,7 @@ static int do_last(struct nameidata *nd, struct path *path,
finish_lookup:
/* we _can_ be in RCU mode here */
error = -ENOENT;
if (!inode || d_is_negative(path->dentry)) {
if (d_is_negative(path->dentry)) {
path_to_nameidata(path, nd);
goto out;
}
Expand Down

0 comments on commit 698934d

Please sign in to comment.