VFS: Combine inode checks with d_is_negative() and d_is_positive() in pathwalk
authorDavid Howells <dhowells@redhat.com>
Tue, 17 Mar 2015 17:33:52 +0000 (17:33 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 15 Apr 2015 19:05:29 +0000 (15:05 -0400)
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>
fs/namei.c

index 76fb76a0818bc274fc67b2d87b582db6690d62a6..5a9291c318815b1b53f770be9af7e92bad263e3a 100644 (file)
@@ -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)) {
@@ -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;
@@ -3038,7 +3038,7 @@ retry_lookup:
 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;
        }