From patchwork Tue May 5 05:22:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 6334231 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0A69DBEEE1 for ; Tue, 5 May 2015 05:26:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17DA620117 for ; Tue, 5 May 2015 05:26:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BCB6202E9 for ; Tue, 5 May 2015 05:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932937AbbEEF0S (ORCPT ); Tue, 5 May 2015 01:26:18 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:40110 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755723AbbEEFXd (ORCPT ); Tue, 5 May 2015 01:23:33 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1YpVJq-0001Ky-BS; Tue, 05 May 2015 05:22:58 +0000 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 33/79] do_last: move path there from caller's stack frame Date: Tue, 5 May 2015 06:22:07 +0100 Message-Id: <1430803373-4948-33-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150505052205.GS889@ZenIV.linux.org.uk> References: <20150505052205.GS889@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro We used to need it to feed to follow_link(). No more... Signed-off-by: Al Viro --- fs/namei.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 72a6130..c5d5e9e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2903,7 +2903,7 @@ out_dput: /* * Handle the last step of open() */ -static int do_last(struct nameidata *nd, struct path *path, +static int do_last(struct nameidata *nd, struct file *file, const struct open_flags *op, int *opened, struct filename *name) { @@ -2914,6 +2914,7 @@ static int do_last(struct nameidata *nd, struct path *path, int acc_mode = op->acc_mode; struct inode *inode; struct path save_parent = { .dentry = NULL, .mnt = NULL }; + struct path path; bool retried = false; int error; @@ -2931,7 +2932,7 @@ static int do_last(struct nameidata *nd, struct path *path, if (nd->last.name[nd->last.len]) nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; /* we _can_ be in RCU mode here */ - error = lookup_fast(nd, path, &inode); + error = lookup_fast(nd, &path, &inode); if (likely(!error)) goto finish_lookup; @@ -2969,7 +2970,7 @@ retry_lookup: */ } mutex_lock(&dir->d_inode->i_mutex); - error = lookup_open(nd, path, file, op, got_write, opened); + error = lookup_open(nd, &path, file, op, got_write, opened); mutex_unlock(&dir->d_inode->i_mutex); if (error <= 0) { @@ -2989,15 +2990,15 @@ retry_lookup: open_flag &= ~O_TRUNC; will_truncate = false; acc_mode = MAY_OPEN; - path_to_nameidata(path, nd); + path_to_nameidata(&path, nd); goto finish_open_created; } /* * create/update audit record if it already exists. */ - if (d_is_positive(path->dentry)) - audit_inode(name, path->dentry, 0); + if (d_is_positive(path.dentry)) + audit_inode(name, path.dentry, 0); /* * If atomic_open() acquired write access it is dropped now due to @@ -3013,7 +3014,7 @@ retry_lookup: if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) goto exit_dput; - error = follow_managed(path, nd->flags); + error = follow_managed(&path, nd->flags); if (error < 0) goto exit_dput; @@ -3021,40 +3022,40 @@ retry_lookup: nd->flags |= LOOKUP_JUMPED; BUG_ON(nd->flags & LOOKUP_RCU); - inode = path->dentry->d_inode; + inode = path.dentry->d_inode; finish_lookup: /* we _can_ be in RCU mode here */ error = -ENOENT; - if (d_is_negative(path->dentry)) { - path_to_nameidata(path, nd); + if (d_is_negative(path.dentry)) { + path_to_nameidata(&path, nd); goto out; } - if (should_follow_link(path->dentry, nd->flags & LOOKUP_FOLLOW)) { + if (should_follow_link(path.dentry, nd->flags & LOOKUP_FOLLOW)) { if (nd->flags & LOOKUP_RCU) { - if (unlikely(nd->path.mnt != path->mnt || - unlazy_walk(nd, path->dentry))) { + if (unlikely(nd->path.mnt != path.mnt || + unlazy_walk(nd, path.dentry))) { error = -ECHILD; goto out; } } - BUG_ON(inode != path->dentry->d_inode); - nd->link = *path; + BUG_ON(inode != path.dentry->d_inode); + nd->link = path; return 1; } - if (unlikely(d_is_symlink(path->dentry)) && !(open_flag & O_PATH)) { - path_to_nameidata(path, nd); + if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) { + path_to_nameidata(&path, nd); error = -ELOOP; goto out; } - if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { - path_to_nameidata(path, nd); + if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) { + path_to_nameidata(&path, nd); } else { save_parent.dentry = nd->path.dentry; - save_parent.mnt = mntget(path->mnt); - nd->path.dentry = path->dentry; + save_parent.mnt = mntget(path.mnt); + nd->path.dentry = path.dentry; } nd->inode = inode; @@ -3116,7 +3117,7 @@ out: return error; exit_dput: - path_put_conditional(path, nd); + path_put_conditional(&path, nd); goto out; exit_fput: fput(file); @@ -3207,7 +3208,6 @@ static struct file *path_openat(int dfd, struct filename *pathname, struct nameidata *nd, const struct open_flags *op, int flags) { struct file *file; - struct path path; int opened = 0; int error; @@ -3226,7 +3226,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, if (unlikely(error)) goto out; - error = do_last(nd, &path, file, op, &opened, pathname); + error = do_last(nd, file, op, &opened, pathname); while (unlikely(error > 0)) { /* trailing symlink */ struct path link = nd->link; void *cookie; @@ -3238,7 +3238,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, error = follow_link(&link, nd, &cookie); if (unlikely(error)) break; - error = do_last(nd, &path, file, op, &opened, pathname); + error = do_last(nd, file, op, &opened, pathname); put_link(nd, &link, cookie); } out: