Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932745AbbEKS17 (ORCPT ); Mon, 11 May 2015 14:27:59 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:47254 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754975AbbEKSIW (ORCPT ); Mon, 11 May 2015 14:08:22 -0400 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 059/110] put_link: nd->depth massage, part 8 Date: Mon, 11 May 2015 19:07:19 +0100 Message-Id: <1431367690-5223-59-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150511180650.GA4147@ZenIV.linux.org.uk> References: <20150511180650.GA4147@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2461 Lines: 96 From: Al Viro all calls are preceded by decrement of nd->depth; move it into put_link() itself. Signed-off-by: Al Viro --- fs/namei.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 9df1c7a..1f61955 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -754,7 +754,7 @@ void nd_jump_link(struct nameidata *nd, struct path *path) static inline void put_link(struct nameidata *nd) { - struct saved *last = nd->stack + nd->depth; + struct saved *last = nd->stack + --nd->depth; struct inode *inode = last->link.dentry->d_inode; if (last->cookie && inode->i_op->put_link) inode->i_op->put_link(last->link.dentry, last->cookie); @@ -1840,7 +1840,6 @@ Walked: err = 0; if (unlikely(!s)) { /* jumped */ - nd->depth--; put_link(nd); } else { if (*s == '/') { @@ -1868,16 +1867,13 @@ Walked: } terminate_walk(nd); Err: - while (unlikely(nd->depth > 1)) { - nd->depth--; + while (unlikely(nd->depth > 1)) put_link(nd); - } return err; OK: if (unlikely(nd->depth > 1)) { name = nd->stack[nd->depth - 1].name; err = walk_component(nd, LOOKUP_FOLLOW); - nd->depth--; put_link(nd); goto Walked; } @@ -2021,12 +2017,9 @@ static int trailing_symlink(struct nameidata *nd) } nd->inode = nd->path.dentry->d_inode; error = link_path_walk(s, nd); - if (unlikely(error)) { - nd->depth--; + if (unlikely(error)) put_link(nd); - return error; - } - return 0; + return error; } static inline int lookup_last(struct nameidata *nd) @@ -2066,7 +2059,6 @@ static int path_lookupat(int dfd, const struct filename *name, if (err) break; err = lookup_last(nd); - nd->depth--; put_link(nd); } } @@ -2416,7 +2408,6 @@ path_mountpoint(int dfd, const struct filename *name, struct path *path, if (err) break; err = mountpoint_last(nd, path); - nd->depth--; put_link(nd); } out: @@ -3301,7 +3292,6 @@ static struct file *path_openat(int dfd, struct filename *pathname, if (unlikely(error)) break; error = do_last(nd, file, op, &opened, pathname); - nd->depth--; put_link(nd); } out: -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/