Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp870602ybv; Sat, 22 Feb 2020 17:18:14 -0800 (PST) X-Google-Smtp-Source: APXvYqyo/NF+Embj9tkMQL+wOQCouij90slJEH/xP2M5fGpoaIzh37CDQtEUHJqWFDNGl+XUvTtL X-Received: by 2002:aca:fcd4:: with SMTP id a203mr7540925oii.167.1582420694270; Sat, 22 Feb 2020 17:18:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582420694; cv=none; d=google.com; s=arc-20160816; b=r58ovcxOeQlP3v03/BDusfHnYXr9JjXwNfRlN1TYM3vun3cfAVV/L95rj8B+9knorr 7Y5hBVNvzhrbAyfiD1UoLcxjJgY1ErYGZwW/LRC2lNLgPaFtotmzsHMW4NK4aulE434Y GAi7AOvlD3jjzNsI7zeA+YqYg7Y4IQ82yW7mXkjwGwfYU0AHmZPJVxkm19xbL8HagtDD scRR/G3QIMR7NUqYNegldWgYCsQLA5AX68fKB4TShV26HkoLIM7TtCLxAy+eLvLw4JqX rYyPbrAA2qehYjh0/V67xwO5PbVGCs53EdC6KbWcUq0PH93lqGxhlukn7/PMayhJjluB 1r/w== 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=CFBc7Yr+TMzzOpz/FOb3Dpt7FhXEyoZdUpG/1G1w+Mg=; b=mN7T0IEPzlVPoP4K+yqXcHwU2beDFTiVg3SBamv86kkUWdDEl9yjMfElwY4iSMu0TC CjsnDzftydJhnyXsMIFZQYestjByYUxPxH2fgheGv9tvQGg7xf4YCE/DtIEQwjY2ooSq kbc4qvACnDLRvj3MAgunT+p5Bo1ITlXEdlSJG4J9cFxz8TwkCAPWWUXWagIUNNo8ZM/j 7CgCX9B5PWr9Q8v3yB6BAbUk/GmN5OzDbt+7yzlsxHSuAo3dHsVqosO4n9x3NPnVbqnJ OKaEr4l61QinWI/KynPBfywoXB3YGiUi7aa0J6jaE3o9KzpvcFHdKtTxvFbz2Sc626Fr 8eIw== 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 w23si4262089otm.256.2020.02.22.17.18.02; Sat, 22 Feb 2020 17:18:14 -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 S1727156AbgBWBRy (ORCPT + 99 others); Sat, 22 Feb 2020 20:17:54 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50104 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbgBWBRy (ORCPT ); Sat, 22 Feb 2020 20:17:54 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j5ftk-00HDb5-Fh; Sun, 23 Feb 2020 01:17:40 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v2 06/34] handle_mounts(): start building a sane wrapper for follow_managed() Date: Sun, 23 Feb 2020 01:15:58 +0000 Message-Id: <20200223011626.4103706-6-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 All callers of follow_managed() follow it on success with the same steps - d_backing_inode(path->dentry) is calculated and stored into some struct inode * variable and, in all but one case, an unsigned variable (nd->seq to be) is zeroed. The single exception is lookup_fast() and there zeroing is correct thing to do - not doing it is a pointless microoptimization. Add a wrapper for follow_managed() that would do that combination. It's mostly a vehicle for code massage - it will be changing quite a bit, and the current calling conventions are by no means final. Right now it takes path, nameidata and (as out params) inode and seq, similar to __follow_mount_rcu(). Which will soon get folded into it... Signed-off-by: Al Viro --- fs/namei.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 6938d20aa73a..c104ec75faef 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1385,6 +1385,18 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, !(path->dentry->d_flags & DCACHE_NEED_AUTOMOUNT); } +static inline int handle_mounts(struct path *path, struct nameidata *nd, + struct inode **inode, unsigned int *seqp) +{ + int ret = follow_managed(path, nd); + + if (likely(ret >= 0)) { + *inode = d_backing_inode(path->dentry); + *seqp = 0; /* out of RCU mode, so the value doesn't matter */ + } + return ret; +} + static int follow_dotdot_rcu(struct nameidata *nd) { struct inode *inode = nd->inode; @@ -1607,7 +1619,6 @@ static int lookup_fast(struct nameidata *nd, struct vfsmount *mnt = nd->path.mnt; struct dentry *dentry, *parent = nd->path.dentry; int status = 1; - int err; /* * Rename seqlock is not required here because in the off chance @@ -1677,10 +1688,7 @@ static int lookup_fast(struct nameidata *nd, path->mnt = mnt; path->dentry = dentry; - err = follow_managed(path, nd); - if (likely(err > 0)) - *inode = d_backing_inode(path->dentry); - return err; + return handle_mounts(path, nd, inode, seqp); } /* Fast lookup failed, do it the slow way */ @@ -1875,12 +1883,9 @@ static int walk_component(struct nameidata *nd, int flags) return PTR_ERR(path.dentry); path.mnt = nd->path.mnt; - err = follow_managed(&path, nd); + err = handle_mounts(&path, nd, &inode, &seq); if (unlikely(err < 0)) return err; - - seq = 0; /* we are already out of RCU mode */ - inode = d_backing_inode(path.dentry); } return step_into(nd, &path, flags, inode, seq); @@ -2365,11 +2370,9 @@ static int handle_lookup_down(struct nameidata *nd) return -ECHILD; } else { dget(path.dentry); - err = follow_managed(&path, nd); + err = handle_mounts(&path, nd, &inode, &seq); if (unlikely(err < 0)) return err; - inode = d_backing_inode(path.dentry); - seq = 0; } path_to_nameidata(&path, nd); nd->inode = inode; @@ -3392,12 +3395,9 @@ static int do_last(struct nameidata *nd, got_write = false; } - error = follow_managed(&path, nd); + error = handle_mounts(&path, nd, &inode, &seq); if (unlikely(error < 0)) return error; - - seq = 0; /* out of RCU mode, so the value doesn't matter */ - inode = d_backing_inode(path.dentry); finish_lookup: error = step_into(nd, &path, 0, inode, seq); if (unlikely(error)) -- 2.11.0