Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1124667ybl; Sat, 18 Jan 2020 19:22:58 -0800 (PST) X-Google-Smtp-Source: APXvYqy6sX7t/NyS0Ho94NLpqr0uJ4Yr5LiW3nWeHndq3VkooapcGMzu91KDUUcbtdO+EFIuq0td X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr11302415otc.123.1579404178742; Sat, 18 Jan 2020 19:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579404178; cv=none; d=google.com; s=arc-20160816; b=KE5oVWRlBgFBMUDVfH4Gm6QjSfJe+ufhUbHs/9DjDm+Z/Cw+abODOy0sl4QwRw9bQB v1yuTuJd3FqHtGcruPY/CMxXCYdP/Y2GokBsCFC3qOCqYt7cpqNGPzfTv6GXqiF0ij6i N64L+Ti8Qik0pR5OoxAsOipcVcuQ43svDRe7CLEYnCD26vzwqP4V7AkRXgil5mKV5YNq M9amQEAaxuaQ0sInkeg22/QE8YXB6TK+H/Bc1GP8jINflpAJBH6Z+sfOfDboERJJAsRY g60TqjkFeieKDSuro37Br5nyp8Zuiz3YHeI5+mA3bXXIv1PwYg8gC8Sk7Z59AjOQ0DYr HY5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/DecaJ6dECWqyBKYPks+9VvysaNo+kpKbcOsk9Y3eqQ=; b=PAFE9BtLRZgrKGvuG4FD6SPUk/5pSLkH2GN8cTfwA0LQ5I2eevmKFoUDUUjjUsDTnK q9i/QIBfLaUt+tc5eSg/98DcpeV3QZRBuDCoK9GlyNw2AqvDmPtABAe6MF0b1r/Ok+z2 pmje6VTuOjB7ZlkP+7QZhlD937YXLaYR/7OvgTGRXDLjHCa7fD4fMnab6aknEsft48cY MQeerzQmt7srXaDHReLocbocVGr9ZH8tTpXXwidgQVJr4kwkcPJTR3N+6wYBMqCN0wBE zWOSX9yMuqeojUGKLnEiP48QwqGB7QEX6+yrWmysziH+fTnaK21GtcTe1Adn/antdSJk uqAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20si17565625otq.157.2020.01.18.19.22.46; Sat, 18 Jan 2020 19:22:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbgASDVm (ORCPT + 99 others); Sat, 18 Jan 2020 22:21:42 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:56812 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgASDVm (ORCPT ); Sat, 18 Jan 2020 22:21:42 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1it197-00BFaq-Jz; Sun, 19 Jan 2020 03:21:13 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Aleksa Sarai , David Howells , Eric Biederman , Christian Brauner , Al Viro Subject: [PATCH 12/17] teach handle_mounts() to handle RCU mode Date: Sun, 19 Jan 2020 03:17:24 +0000 Message-Id: <20200119031738.2681033-12-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200119031738.2681033-1-viro@ZenIV.linux.org.uk> References: <20200119031423.GV8904@ZenIV.linux.org.uk> <20200119031738.2681033-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 2e416bd8ee26..a3bed1307a4b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1312,6 +1312,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); @@ -1527,7 +1539,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; @@ -1565,21 +1576,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)) @@ -2229,21 +2227,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.20.1