From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5698CC10DCE for ; Fri, 13 Mar 2020 23:58:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35A0A20637 for ; Fri, 13 Mar 2020 23:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728043AbgCMX6K (ORCPT ); Fri, 13 Mar 2020 19:58:10 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:49990 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbgCMXx7 (ORCPT ); Fri, 13 Mar 2020 19:53:59 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCu7q-00B6ZI-LQ; Fri, 13 Mar 2020 23:53:58 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v4 12/69] teach handle_mounts() to handle RCU mode Date: Fri, 13 Mar 2020 23:53:00 +0000 Message-Id: <20200313235357.2646756-12-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> References: <20200313235303.GP23230@ZenIV.linux.org.uk> <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro ... and make the callers of __follow_mount_rcu() use handle_mounts(). Signed-off-by: Al Viro --- fs/namei.c | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 494f4959e790..37b2f82e6f2c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1393,6 +1393,18 @@ static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry, path->mnt = nd->path.mnt; path->dentry = dentry; + if (nd->flags & LOOKUP_RCU) { + unsigned int seq = *seqp; + if (unlikely(!*inode)) + return -ENOENT; + if (likely(__follow_mount_rcu(nd, path, inode, seqp))) + return 1; + if (unlazy_child(nd, dentry, seq)) + return -ECHILD; + // *path might've been clobbered by __follow_mount_rcu() + path->mnt = nd->path.mnt; + path->dentry = dentry; + } ret = follow_managed(path, nd); if (likely(ret >= 0)) { *inode = d_backing_inode(path->dentry); @@ -1620,7 +1632,6 @@ static int lookup_fast(struct nameidata *nd, struct path *path, struct inode **inode, unsigned *seqp) { - struct vfsmount *mnt = nd->path.mnt; struct dentry *dentry, *parent = nd->path.dentry; int status = 1; @@ -1658,21 +1669,8 @@ static int lookup_fast(struct nameidata *nd, *seqp = seq; status = d_revalidate(dentry, nd->flags); - if (likely(status > 0)) { - /* - * Note: do negative dentry check after revalidation in - * case that drops it. - */ - if (unlikely(!inode)) - return -ENOENT; - path->mnt = mnt; - path->dentry = dentry; - if (likely(__follow_mount_rcu(nd, path, inode, seqp))) - return 1; - if (unlazy_child(nd, dentry, seq)) - return -ECHILD; + if (likely(status > 0)) return handle_mounts(nd, dentry, path, inode, seqp); - } if (unlazy_child(nd, dentry, seq)) return -ECHILD; if (unlikely(status == -ECHILD)) @@ -2361,21 +2359,11 @@ static int handle_lookup_down(struct nameidata *nd) unsigned seq = nd->seq; int err; - if (nd->flags & LOOKUP_RCU) { - /* - * don't bother with unlazy_walk on failure - we are - * at the very beginning of walk, so we lose nothing - * if we simply redo everything in non-RCU mode - */ - path = nd->path; - if (unlikely(!__follow_mount_rcu(nd, &path, &inode, &seq))) - return -ECHILD; - } else { + if (!(nd->flags & LOOKUP_RCU)) dget(nd->path.dentry); - err = handle_mounts(nd, nd->path.dentry, &path, &inode, &seq); - if (unlikely(err < 0)) - return err; - } + err = handle_mounts(nd, nd->path.dentry, &path, &inode, &seq); + if (unlikely(err < 0)) + return err; path_to_nameidata(&path, nd); nd->inode = inode; nd->seq = seq; -- 2.11.0