From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754841AbbDTSNj (ORCPT ); Mon, 20 Apr 2015 14:13:39 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:34780 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754301AbbDTSNN (ORCPT ); Mon, 20 Apr 2015 14:13:13 -0400 From: Al Viro To: Linus Torvalds Cc: Neil Brown , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 22/24] namei: trim the arguments of get_link() Date: Mon, 20 Apr 2015 19:13:06 +0100 Message-Id: <1429553588-24764-22-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150420181222.GK889@ZenIV.linux.org.uk> References: <20150420181222.GK889@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro same story as the previous commit Signed-off-by: Al Viro --- fs/namei.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index a8d6751..425986a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -878,10 +878,10 @@ static int may_linkat(struct path *link) return -EPERM; } -static __always_inline char * -get_link(struct path *link, struct nameidata *nd, void **p) +static __always_inline char *get_link(struct nameidata *nd, struct path *next) { - struct dentry *dentry = link->dentry; + struct saved *last = nd->stack + nd->depth; + struct dentry *dentry = next->dentry; struct inode *inode = dentry->d_inode; void *cookie; int error; @@ -889,8 +889,10 @@ get_link(struct path *link, struct nameidata *nd, void **p) BUG_ON(nd->flags & LOOKUP_RCU); - if (link->mnt == nd->path.mnt) - mntget(link->mnt); + if (next->mnt == nd->path.mnt) + mntget(next->mnt); + + last->link = *next; res = ERR_PTR(-ELOOP); if (unlikely(nd->total_link_count >= 40)) @@ -899,7 +901,7 @@ get_link(struct path *link, struct nameidata *nd, void **p) cond_resched(); nd->total_link_count++; - touch_atime(link); + touch_atime(&last->link); nd_set_link(NULL); error = security_inode_follow_link(dentry); @@ -914,16 +916,16 @@ get_link(struct path *link, struct nameidata *nd, void **p) res = nd_get_link(nd); if (!IS_ERR(res)) { - *p = cookie; + last->cookie = cookie; return res; } if (inode->i_op->put_link) inode->i_op->put_link(dentry, res, cookie); out: - *p = NULL; + last->cookie = NULL; path_put(&nd->path); - path_put(link); + path_put(&last->link); return res; } @@ -931,12 +933,10 @@ static int follow_link(struct nameidata *nd, struct path *link) { char *s; int error = may_follow_link(link, nd); - struct saved *last = nd->stack + nd->depth; if (unlikely(error)) return error; nd->flags |= LOOKUP_PARENT; - last->link = *link; - s = get_link(&last->link, nd, &last->cookie); + s = get_link(nd, link); if (unlikely(IS_ERR(s))) return PTR_ERR(s); if (unlikely(!s)) @@ -1779,7 +1779,6 @@ static inline u64 hash_name(const char *name) */ static int link_path_walk(const char *name, struct nameidata *nd) { - struct saved *last = nd->stack; struct path next; int err; @@ -1858,16 +1857,13 @@ Walked: nd->depth++; nd->link_count++; - last++; - last->link = next; - s = get_link(&last->link, nd, &last->cookie); + s = get_link(nd, &next); if (unlikely(IS_ERR(s))) { err = PTR_ERR(s); nd->link_count--; nd->depth--; - last--; goto Err; } err = 0; @@ -1876,7 +1872,6 @@ Walked: put_link(nd); nd->link_count--; nd->depth--; - last--; } else { if (*s == '/') { if (!nd->root.mnt) @@ -1889,7 +1884,7 @@ Walked: ; } nd->inode = nd->path.dentry->d_inode; - last->name = name; + nd->stack[nd->depth].name = name; if (!*s) goto OK; name = s; @@ -1907,17 +1902,15 @@ Err: put_link(nd); nd->link_count--; nd->depth--; - last--; } return err; OK: if (unlikely(nd->depth)) { - name = last->name; + name = nd->stack[nd->depth].name; err = walk_component(nd, &next, LOOKUP_FOLLOW); put_link(nd); nd->link_count--; nd->depth--; - last--; goto Walked; } return 0; -- 2.1.4