Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp637803imw; Mon, 4 Jul 2022 16:48:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcTt96IVZ+AoVUb8es/zeNQOFTUiyEvoVTXGKInCfInOENC+B7gJiwmmp4b5i5ci7rHoc0 X-Received: by 2002:a17:902:f609:b0:168:dcbe:7c4d with SMTP id n9-20020a170902f60900b00168dcbe7c4dmr14935978plg.169.1656978528452; Mon, 04 Jul 2022 16:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656978528; cv=none; d=google.com; s=arc-20160816; b=Pgv9reBdulqHLMhCsimljiIJkDQqNxYBD5seksS/qwYmxKBrLasodc6UeK+57f4a2k pGpIA/MF9LcNwz434mpOaCKbovm2RYGmxhYa5hQl5ma+jHWpf3T5cuUTDXPCh2VIGd9z 1Eu4T2WIyHfk2O2QLteZU7rufFNX3vn9UnhYM4dSbjaLM4lWY2Cx9skqhUlYBbCo3oEo PIJ66cwlCC5hYNd083SfAl6DdVpXoBMaVJ/A7U6tzZIXC0AWtzDAUV7oOeRJihrqudW3 pxLsXYSeqBvAJjzT+53lY6pLdbYQ1RDBSGXkojr5zSDlsGscD9fC7VihFWTtT4p12Qfv 0YTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=yVde6OT5Ehv5tuk0crezw61+e6oS2AMOyyAHAkO3zT4=; b=PTSVNyAObp18eWdF2tbsEiv92gmO0Hnm2RkzBHtXR3nlLH9wfL5hmTkFOrSDSfVxf2 JfVzH3oq9Fb+h6az1mMaInHK/EoD70LIWwd5O/4RnCkOh2EX1SOvDnqkspTwNMnR+Uji tBLFVO3nyNBJ8ifU6C5vBafMP/ZC9LuGHvBc2q7LZ9/Nf3aV05sy11QvPUBv5K1SDt9o Aqhsar4uAS+eMoBb4oA1bnXkCMeMzms5mxCPXu07cTp/Fdh5+HWYXhVecBKY9cy/D0SP qJdpA3oED+mxfwnxvimxljdhmzpWLh3rD4hit3ZA/Cw7Yf7CDnZ8QOKFzhmEROYJbf6o ED5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=sWOTLQXm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id em18-20020a17090b015200b001ef7c6a679fsi8063979pjb.105.2022.07.04.16.48.31; Mon, 04 Jul 2022 16:48:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=sWOTLQXm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233866AbiGDXOs (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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