do_last(): collapse the call of path_to_nameidata()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 9 Jan 2020 19:30:08 +0000 (14:30 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 12 Mar 2020 22:15:42 +0000 (18:15 -0400)
... and shift filling struct path to just before the call of
handle_mounts().  All callers of handle_mounts() are
immediately preceded by path->mnt = nd->path.mnt now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index b350e1e..79029a1 100644 (file)
@@ -3362,8 +3362,6 @@ static int do_last(struct nameidata *nd,
                error = PTR_ERR(dentry);
                goto out;
        }
-       path.mnt = nd->path.mnt;
-       path.dentry = dentry;
 
        if (file->f_mode & FMODE_OPENED) {
                if ((file->f_mode & FMODE_CREATED) ||
@@ -3380,7 +3378,8 @@ static int do_last(struct nameidata *nd,
                open_flag &= ~O_TRUNC;
                will_truncate = false;
                acc_mode = 0;
-               path_to_nameidata(&path, nd);
+               dput(nd->path.dentry);
+               nd->path.dentry = dentry;
                goto finish_open_created;
        }
 
@@ -3394,6 +3393,8 @@ static int do_last(struct nameidata *nd,
                got_write = false;
        }
 
+       path.mnt = nd->path.mnt;
+       path.dentry = dentry;
        error = handle_mounts(&path, nd, &inode, &seq);
        if (unlikely(error < 0))
                return error;