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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25E8FC47082 for ; Thu, 3 Jun 2021 14:51:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2468613E7 for ; Thu, 3 Jun 2021 14:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbhFCOwx (ORCPT ); Thu, 3 Jun 2021 10:52:53 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:59368 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbhFCOwx (ORCPT ); Thu, 3 Jun 2021 10:52:53 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1loogd-000T5b-6m; Thu, 03 Jun 2021 08:51:07 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=email.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1loogc-000VSc-41; Thu, 03 Jun 2021 08:51:06 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Ian Kent Cc: Greg Kroah-Hartman , Tejun Heo , Eric Sandeen , Fox Chen , Brice Goglin , Al Viro , Rick Lindsley , David Howells , Miklos Szeredi , Marcelo Tosatti , linux-fsdevel , Kernel Mailing List References: <162218354775.34379.5629941272050849549.stgit@web.messagingengine.com> <162218363530.34379.16741129191900256265.stgit@web.messagingengine.com> Date: Thu, 03 Jun 2021 09:50:34 -0500 In-Reply-To: <162218363530.34379.16741129191900256265.stgit@web.messagingengine.com> (Ian Kent's message of "Fri, 28 May 2021 14:33:55 +0800") Message-ID: <87im2vq9xh.fsf@disp2133> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1loogc-000VSc-41;;;mid=<87im2vq9xh.fsf@disp2133>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/bKCwWNjTqbcYtNY+PUXv6nJdZuHoj4m4= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [REPOST PATCH v4 1/5] kernfs: move revalidate to be near lookup X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Ian Kent writes: > While the dentry operation kernfs_dop_revalidate() is grouped with > dentry type functions it also has a strong affinity to the inode > operation ->lookup(). > > In order to take advantage of the VFS negative dentry caching that > can be used to reduce path lookup overhead on non-existent paths it > will need to call kernfs_find_ns(). So, to avoid a forward declaration, > move it to be near kernfs_iop_lookup(). > > There's no functional change from this patch. Does this patch compile independently? During the code movement kernfs_active is replaced by kernfs_active_read which does not exist yet. Eric > Signed-off-by: Ian Kent > --- > fs/kernfs/dir.c | 86 ++++++++++++++++++++++++++++--------------------------- > 1 file changed, 43 insertions(+), 43 deletions(-) > > diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c > index 7e0e62deab53c..4c69e2af82dac 100644 > --- a/fs/kernfs/dir.c > +++ b/fs/kernfs/dir.c > @@ -548,49 +548,6 @@ void kernfs_put(struct kernfs_node *kn) > } > EXPORT_SYMBOL_GPL(kernfs_put); > > -static int kernfs_dop_revalidate(struct dentry *dentry, unsigned int flags) > -{ > - struct kernfs_node *kn; > - > - if (flags & LOOKUP_RCU) > - return -ECHILD; > - > - /* Always perform fresh lookup for negatives */ > - if (d_really_is_negative(dentry)) > - goto out_bad_unlocked; > - > - kn = kernfs_dentry_node(dentry); > - mutex_lock(&kernfs_mutex); > - > - /* The kernfs node has been deactivated */ > - if (!kernfs_active(kn)) > - goto out_bad; > - > - /* The kernfs node has been moved? */ > - if (kernfs_dentry_node(dentry->d_parent) != kn->parent) > - goto out_bad; > - > - /* The kernfs node has been renamed */ > - if (strcmp(dentry->d_name.name, kn->name) != 0) > - goto out_bad; > - > - /* The kernfs node has been moved to a different namespace */ > - if (kn->parent && kernfs_ns_enabled(kn->parent) && > - kernfs_info(dentry->d_sb)->ns != kn->ns) > - goto out_bad; > - > - mutex_unlock(&kernfs_mutex); > - return 1; > -out_bad: > - mutex_unlock(&kernfs_mutex); > -out_bad_unlocked: > - return 0; > -} > - > -const struct dentry_operations kernfs_dops = { > - .d_revalidate = kernfs_dop_revalidate, > -}; > - > /** > * kernfs_node_from_dentry - determine kernfs_node associated with a dentry > * @dentry: the dentry in question > @@ -1073,6 +1030,49 @@ struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent, > return ERR_PTR(rc); > } > > +static int kernfs_dop_revalidate(struct dentry *dentry, unsigned int flags) > +{ > + struct kernfs_node *kn; > + > + if (flags & LOOKUP_RCU) > + return -ECHILD; > + > + /* Always perform fresh lookup for negatives */ > + if (d_really_is_negative(dentry)) > + goto out_bad_unlocked; > + > + kn = kernfs_dentry_node(dentry); > + mutex_lock(&kernfs_mutex); > + > + /* The kernfs node has been deactivated */ > + if (!kernfs_active_read(kn)) > + goto out_bad; > + > + /* The kernfs node has been moved? */ > + if (kernfs_dentry_node(dentry->d_parent) != kn->parent) > + goto out_bad; > + > + /* The kernfs node has been renamed */ > + if (strcmp(dentry->d_name.name, kn->name) != 0) > + goto out_bad; > + > + /* The kernfs node has been moved to a different namespace */ > + if (kn->parent && kernfs_ns_enabled(kn->parent) && > + kernfs_info(dentry->d_sb)->ns != kn->ns) > + goto out_bad; > + > + mutex_unlock(&kernfs_mutex); > + return 1; > +out_bad: > + mutex_unlock(&kernfs_mutex); > +out_bad_unlocked: > + return 0; > +} > + > +const struct dentry_operations kernfs_dops = { > + .d_revalidate = kernfs_dop_revalidate, > +}; > + > static struct dentry *kernfs_iop_lookup(struct inode *dir, > struct dentry *dentry, > unsigned int flags)