Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp872652ybv; Sat, 22 Feb 2020 17:20:54 -0800 (PST) X-Google-Smtp-Source: APXvYqycJYjwJPfPF6UsXFf/U8OkpjH6I3+mYwc0SG8TZ0L7yeVkXYBoa4dJ/bSLZii2eknFHqiN X-Received: by 2002:a9d:634c:: with SMTP id y12mr21076283otk.12.1582420854777; Sat, 22 Feb 2020 17:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582420854; cv=none; d=google.com; s=arc-20160816; b=h3czwNZrtqZqlGRNKxac4UUgkaDjOW/eo7Oj5n8NzjznXB/iWoYGCRpB7cuV5vawlh DKEie6VO3nn1+9zco+DyhU1KhZLYnjl31JfRZI6UFfgXWtK0LLz3956L654slE/gAktl bdylCQcypzBpZ527ni8im0Ap/eXB4i4/sBRVEzaie8ff7bG8O6EeSVzl2yTmKfW/I2dn ZMLYXvbH8v3FcGN9DJnHlOUoHWcnMbBmbo4nlcCUY207PggZnQkOa7C1esmvP5n1Vc6N JP8pyq9Dfa9LfAUsUTGaMMlIWpefa3inVUSqbM1pqGDcnxYvGPST/pnql9fGoV2UJtPQ Ia9w== 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=R+ZlX4vcFuxqQQJhGOx2nhvptCYtdHCX9F72IsAQV/4=; b=qWLVEI44Ek9LR702AfOZJw+uN561kq4a/kP4mAKHXGyVZbnTV+wfKfUM6ZyY7Cev6I 8ez0UWxbGYec3vYCb7VDQHjn+09G1TGss47ZHMx2hDzImHq/wE1z3vLUlLppqvUgOQW6 gbUgLLAa2O7uSZ+xlAdWEPGyUOfgJlvCr+nBoCoszTCRJOIHn+44uwYwvIjW8564FUIE RLy3x0+pdPChmA4hrL1XYMQBBTP/trXrrUZ6wIcJ/QOTm2YIbG29YoYozGYuP4WLulKb O4MuM0w/5AkA+dAPWDxkmFdsUco+l3qeDXFnMgu//Uy/shYPCpKW94Cy2VVl943mpUhd SO6w== 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 j9si3712594otl.153.2020.02.22.17.20.43; Sat, 22 Feb 2020 17:20:54 -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 S1727210AbgBWBTs (ORCPT + 99 others); Sat, 22 Feb 2020 20:19:48 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50144 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbgBWBTs (ORCPT ); Sat, 22 Feb 2020 20:19:48 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j5fvh-00HDeS-MZ; Sun, 23 Feb 2020 01:19:42 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v2 12/34] teach handle_mounts() to handle RCU mode Date: Sun, 23 Feb 2020 01:16:04 +0000 Message-Id: <20200223011626.4103706-12-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200223011626.4103706-1-viro@ZenIV.linux.org.uk> References: <20200223011154.GY23230@ZenIV.linux.org.uk> <20200223011626.4103706-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 53e859b80b4c..3215b0da6e91 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