From patchwork Mon Oct 14 12:26:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 3036111 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 885A89F243 for ; Mon, 14 Oct 2013 12:29:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F07C2021A for ; Mon, 14 Oct 2013 12:29:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 30DB020219 for ; Mon, 14 Oct 2013 12:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932146Ab3JNM2c (ORCPT ); Mon, 14 Oct 2013 08:28:32 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:64609 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932145Ab3JNM2b (ORCPT ); Mon, 14 Oct 2013 08:28:31 -0400 Received: from 172.24.2.119 (EHLO szxeml208-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BJF67863; Mon, 14 Oct 2013 20:27:00 +0800 (CST) Received: from SZXEML452-HUB.china.huawei.com (10.82.67.195) by szxeml208-edg.china.huawei.com (172.24.2.57) with Microsoft SMTP Server (TLS) id 14.3.146.0; Mon, 14 Oct 2013 20:26:59 +0800 Received: from localhost (10.135.68.221) by szxeml452-hub.china.huawei.com (10.82.67.195) with Microsoft SMTP Server id 14.3.146.0; Mon, 14 Oct 2013 20:26:54 +0800 From: Kefeng Wang To: Alexander Viro CC: John McCutchan , "J. Bruce Fields" , Eric Paris , Robert Love , , , Subject: [PATCH 1/3] fs: use path_equal() and path_put() to simplify code Date: Mon, 14 Oct 2013 20:26:00 +0800 Message-ID: <1381753562-47884-2-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 1.8.3.msysgit.0 In-Reply-To: <1381753562-47884-1-git-send-email-wangkefeng.wang@huawei.com> References: <1381753562-47884-1-git-send-email-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.68.221] X-CFilter-Loop: Reflected Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Signed-off-by: Kefeng Wang --- fs/namei.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 645268f..1a6c139 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -918,9 +918,8 @@ int follow_up(struct path *path) mntget(&parent->mnt); mountpoint = dget(mnt->mnt_mountpoint); br_read_unlock(&vfsmount_lock); - dput(path->dentry); + path_put(path); path->dentry = mountpoint; - mntput(path->mnt); path->mnt = &parent->mnt; return 1; } @@ -1077,8 +1076,7 @@ int follow_down_one(struct path *path) mounted = lookup_mnt(path); if (mounted) { - dput(path->dentry); - mntput(path->mnt); + path_put(path); path->mnt = mounted; path->dentry = dget(mounted->mnt_root); return 1; @@ -1146,10 +1144,8 @@ static int follow_dotdot_rcu(struct nameidata *nd) set_root_rcu(nd); while (1) { - if (nd->path.dentry == nd->root.dentry && - nd->path.mnt == nd->root.mnt) { + if (path_equal(&nd->path, &nd->root)) break; - } if (nd->path.dentry != nd->path.mnt->mnt_root) { struct dentry *old = nd->path.dentry; struct dentry *parent = old->d_parent; @@ -1214,8 +1210,7 @@ int follow_down(struct path *path) struct vfsmount *mounted = lookup_mnt(path); if (!mounted) break; - dput(path->dentry); - mntput(path->mnt); + path_put(path); path->mnt = mounted; path->dentry = dget(mounted->mnt_root); continue; @@ -1236,8 +1231,7 @@ static void follow_mount(struct path *path) struct vfsmount *mounted = lookup_mnt(path); if (!mounted) break; - dput(path->dentry); - mntput(path->mnt); + path_put(path); path->mnt = mounted; path->dentry = dget(mounted->mnt_root); } @@ -1250,10 +1244,8 @@ static void follow_dotdot(struct nameidata *nd) while(1) { struct dentry *old = nd->path.dentry; - if (nd->path.dentry == nd->root.dentry && - nd->path.mnt == nd->root.mnt) { + if (path_equal(&nd->path, &nd->root)) break; - } if (nd->path.dentry != nd->path.mnt->mnt_root) { /* rare case of legitimate dget_parent()... */ nd->path.dentry = dget_parent(nd->path.dentry);