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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E52AC43334 for ; Mon, 4 Jul 2022 23:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233864AbiGDXOs (ORCPT ); Mon, 4 Jul 2022 19:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbiGDXOq (ORCPT ); Mon, 4 Jul 2022 19:14:46 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77A8FF5A2; Mon, 4 Jul 2022 16:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yVde6OT5Ehv5tuk0crezw61+e6oS2AMOyyAHAkO3zT4=; b=sWOTLQXmpJ5PfJPX0D6RfCVV8H y3xvhrfTU2W/13c3jKVExU64lREaPCNI3kLc87vy8xbN53d6RWOm7HLmvowNV6yO9umwHHEAxLltY g2fm+8ci7srGfVRTbgBwK/yZQXOgy3zEFEDvsGtjfdWGQoLQwIOshkKMw/1Kl9PU/RVxAYHUiWxNZ Mr9lfga8Boj5cohoAiN5fnfAx/unPr6CJUFNRlggKGbOWN085O604eoaLlqaIXnbM5inZ36arEOnz hbuh9jANU1BzNfmrKbsuK7nALZC7ZsGGbtXshIOeCy/+I8XqbB9DmkUwjfoHo6GSSZPD/NgZip9rM leAOLVMw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.95 #2 (Red Hat Linux)) id 1o8VGd-008AW9-Ka; Mon, 04 Jul 2022 23:14:11 +0000 Date: Tue, 5 Jul 2022 00:14:11 +0100 From: Al Viro To: Linus Torvalds Cc: Alexander Potapenko , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev , Linux-MM , linux-arch , Linux Kernel Mailing List , Evgenii Stepanov , Nathan Chancellor , Nick Desaulniers , Segher Boessenkool , Vitaly Buka , linux-toolchains Subject: [PATCH 2/7] follow_dotdot{,_rcu}(): change calling conventions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of returning NULL when we are in root, just make it return the current position (and set *seqp and *inodep accordingly). That collapses the calls of step_into() in handle_dots() Signed-off-by: Al Viro --- fs/namei.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 4dbf55b37ec6..ecdb9ac21ece 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1909,7 +1909,9 @@ static struct dentry *follow_dotdot_rcu(struct nameidata *nd, return ERR_PTR(-ECHILD); if (unlikely(nd->flags & LOOKUP_BENEATH)) return ERR_PTR(-ECHILD); - return NULL; + *seqp = nd->seq; + *inodep = nd->path.dentry->d_inode; + return nd->path.dentry; } static struct dentry *follow_dotdot(struct nameidata *nd, @@ -1945,8 +1947,9 @@ static struct dentry *follow_dotdot(struct nameidata *nd, in_root: if (unlikely(nd->flags & LOOKUP_BENEATH)) return ERR_PTR(-EXDEV); - dget(nd->path.dentry); - return NULL; + *seqp = 0; + *inodep = nd->path.dentry->d_inode; + return dget(nd->path.dentry); } static const char *handle_dots(struct nameidata *nd, int type) @@ -1968,12 +1971,7 @@ static const char *handle_dots(struct nameidata *nd, int type) parent = follow_dotdot(nd, &inode, &seq); if (IS_ERR(parent)) return ERR_CAST(parent); - if (unlikely(!parent)) - error = step_into(nd, WALK_NOFOLLOW, - nd->path.dentry, nd->inode, nd->seq); - else - error = step_into(nd, WALK_NOFOLLOW, - parent, inode, seq); + error = step_into(nd, WALK_NOFOLLOW, parent, inode, seq); if (unlikely(error)) return error; -- 2.30.2