From patchwork Wed May 13 22:26:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 6400871 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 86FD89F1C2 for ; Wed, 13 May 2015 22:29:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89E0D20411 for ; Wed, 13 May 2015 22:29:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6121A203EB for ; Wed, 13 May 2015 22:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965783AbbEMW3T (ORCPT ); Wed, 13 May 2015 18:29:19 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:44946 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965518AbbEMW0V (ORCPT ); Wed, 13 May 2015 18:26:21 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1Ysf6X-0006nI-Ln; Wed, 13 May 2015 22:26:17 +0000 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 20/21] namei: move saved_nd pointer into struct nameidata Date: Wed, 13 May 2015 23:26:14 +0100 Message-Id: <1431555975-25997-20-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150513222533.GA24192@ZenIV.linux.org.uk> References: <20150513222533.GA24192@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 these guys are always declared next to each other; might as well put the former (pointer to previous instance) into the latter and simplify the calling conventions for {set,restore}_nameidata() Signed-off-by: Al Viro --- fs/namei.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 23dd9e8..dead60d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -498,10 +498,8 @@ struct nameidata { struct qstr last; struct path root; struct inode *inode; /* path.dentry.d_inode */ - struct filename *name; - int dfd; unsigned int flags; - unsigned seq, m_seq, root_seq; + unsigned seq, m_seq; int last_type; unsigned depth; int total_link_count; @@ -512,23 +510,26 @@ struct nameidata { struct inode *inode; unsigned seq; } *stack, internal[EMBEDDED_LEVELS]; + struct filename *name; + struct nameidata *saved; + unsigned root_seq; + int dfd; }; -static struct nameidata *set_nameidata(struct nameidata *p, int dfd, - struct filename *name) +static void set_nameidata(struct nameidata *p, int dfd, struct filename *name) { struct nameidata *old = current->nameidata; p->stack = p->internal; p->dfd = dfd; p->name = name; p->total_link_count = old ? old->total_link_count : 0; + p->saved = old; current->nameidata = p; - return old; } -static void restore_nameidata(struct nameidata *old) +static void restore_nameidata(void) { - struct nameidata *now = current->nameidata; + struct nameidata *now = current->nameidata, *old = now->saved; current->nameidata = old; if (old) @@ -2118,14 +2119,14 @@ static int filename_lookup(int dfd, struct filename *name, unsigned flags, struct path *path, struct path *root) { int retval; - struct nameidata nd, *saved_nd; + struct nameidata nd; if (IS_ERR(name)) return PTR_ERR(name); - saved_nd = set_nameidata(&nd, dfd, name); if (unlikely(root)) { nd.root = *root; flags |= LOOKUP_ROOT; } + set_nameidata(&nd, dfd, name); retval = path_lookupat(&nd, flags | LOOKUP_RCU, path); if (unlikely(retval == -ECHILD)) retval = path_lookupat(&nd, flags, path); @@ -2134,7 +2135,7 @@ static int filename_lookup(int dfd, struct filename *name, unsigned flags, if (likely(!retval)) audit_inode(name, path->dentry, flags & LOOKUP_PARENT); - restore_nameidata(saved_nd); + restore_nameidata(); putname(name); return retval; } @@ -2164,11 +2165,11 @@ static struct filename *filename_parentat(int dfd, struct filename *name, struct qstr *last, int *type) { int retval; - struct nameidata nd, *saved_nd; + struct nameidata nd; if (IS_ERR(name)) return name; - saved_nd = set_nameidata(&nd, dfd, name); + set_nameidata(&nd, dfd, name); retval = path_parentat(&nd, flags | LOOKUP_RCU, parent); if (unlikely(retval == -ECHILD)) retval = path_parentat(&nd, flags, parent); @@ -2182,7 +2183,7 @@ static struct filename *filename_parentat(int dfd, struct filename *name, putname(name); name = ERR_PTR(retval); } - restore_nameidata(saved_nd); + restore_nameidata(); return name; } @@ -2443,11 +2444,11 @@ static int filename_mountpoint(int dfd, struct filename *name, struct path *path, unsigned int flags) { - struct nameidata nd, *saved; + struct nameidata nd; int error; if (IS_ERR(name)) return PTR_ERR(name); - saved = set_nameidata(&nd, dfd, name); + set_nameidata(&nd, dfd, name); error = path_mountpoint(&nd, flags | LOOKUP_RCU, path); if (unlikely(error == -ECHILD)) error = path_mountpoint(&nd, flags, path); @@ -2455,7 +2456,7 @@ filename_mountpoint(int dfd, struct filename *name, struct path *path, error = path_mountpoint(&nd, flags | LOOKUP_REVAL, path); if (likely(!error)) audit_inode(name, path->dentry, 0); - restore_nameidata(saved); + restore_nameidata(); putname(name); return error; } @@ -3325,23 +3326,24 @@ out2: struct file *do_filp_open(int dfd, struct filename *pathname, const struct open_flags *op) { - struct nameidata nd, *saved_nd = set_nameidata(&nd, dfd, pathname); + struct nameidata nd; int flags = op->lookup_flags; struct file *filp; + set_nameidata(&nd, dfd, pathname); filp = path_openat(&nd, op, flags | LOOKUP_RCU); if (unlikely(filp == ERR_PTR(-ECHILD))) filp = path_openat(&nd, op, flags); if (unlikely(filp == ERR_PTR(-ESTALE))) filp = path_openat(&nd, op, flags | LOOKUP_REVAL); - restore_nameidata(saved_nd); + restore_nameidata(); return filp; } struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, const char *name, const struct open_flags *op) { - struct nameidata nd, *saved_nd; + struct nameidata nd; struct file *file; struct filename *filename; int flags = op->lookup_flags | LOOKUP_ROOT; @@ -3356,13 +3358,13 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, if (unlikely(IS_ERR(filename))) return ERR_CAST(filename); - saved_nd = set_nameidata(&nd, -1, filename); + set_nameidata(&nd, -1, filename); file = path_openat(&nd, op, flags | LOOKUP_RCU); if (unlikely(file == ERR_PTR(-ECHILD))) file = path_openat(&nd, op, flags); if (unlikely(file == ERR_PTR(-ESTALE))) file = path_openat(&nd, op, flags | LOOKUP_REVAL); - restore_nameidata(saved_nd); + restore_nameidata(); putname(filename); return file; }