Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp291664ybt; Wed, 17 Jun 2020 00:41:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpf2sCYnnCRCyGdXj0WfQHEP24jE1GO2YUCXx+ixcUn6DmTnIYcwTKxClOHMJS8R48VL4W X-Received: by 2002:a17:906:4350:: with SMTP id z16mr6230446ejm.139.1592379679506; Wed, 17 Jun 2020 00:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592379679; cv=none; d=google.com; s=arc-20160816; b=BKvRV/UP3s8AH0gU2FYW52cgm2uCUkC5nQbQLv38esUFZB5LMG16cvktgtdHDemQa2 wnTw1ES/6ekffEKB4sh2vNLW1cXJ+SR04kIQR46kRG08qTvGQ8CcNR0bBoGb1HKosjkJ hB7TCxrncn+pT1T/1jypA3vmADOe+ff75wXoc9KYZW/ytMJKjYcy8aF14QA5okIMYPW3 PfVwpykcN5uswTgfw1fwRFp9OzigN7arjbzjZ39+pbrRn954dfRPsKQjq1JELVAb0eQh JhDuNWtTPa/YnHDK2shCSrJr9nAwxnLLFXFQ7rwQzxFjIasAN1zurt5B1Qxlk4SjznEh wNOQ== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=FtR+UgOOZLBiQrxLIVMV0q/xz8NJCgPfEh2OWV3jrgA=; b=JQoKS7A2c0u4XwDtxtplSo6KEVfeLQBkBNfwS4LnMQhV7HkQk8a6RO+30P9qMT2vBB DyPAJLe7y+9dCDX4ycPMvoJAyEZdjq+T1L6hKa5IebC8asJYzL27IWRRaxxsHqo88md0 yivd8Y+oj06eiCLJnCjvMO+jcWip2sw7kTSYq+aCHJ+vO9tBSqF+vl+wFT1pbFOLI3iK wlPykbKnZeUeoVKOzHBxVQ4hg3OlIX4vUulLqrEp2PGKlttAjA4gSiiARMlaGexo9v/9 dxUA9ay5utRlr3kAPnSQDEjWGK4asuXYepIg6YMzXypGiVDdOdjrll9YYKm9Lf1OG6g4 /HfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b=rMMRedoE; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Qkg0mF0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj1si12485906ejb.668.2020.06.17.00.40.57; Wed, 17 Jun 2020 00:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b=rMMRedoE; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Qkg0mF0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbgFQHiD (ORCPT + 99 others); Wed, 17 Jun 2020 03:38:03 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:49597 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbgFQHh6 (ORCPT ); Wed, 17 Jun 2020 03:37:58 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id C652C5B1; Wed, 17 Jun 2020 03:37:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 17 Jun 2020 03:37:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h= subject:from:to:cc:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm3; bh= FtR+UgOOZLBiQrxLIVMV0q/xz8NJCgPfEh2OWV3jrgA=; b=rMMRedoET73KVhcm v5wamPEc6LIuFh66Ri5S1XuHBwvm7ZuAdQH2nnX9TcSLKr19InvPfMHoq8DWEmqc dvS/4fF0E+F/c1bK/Ftbt0XqxKNig8D3clbR94gs7HPsSeNIM/BRHZn9t1aMeFsd LglU7Y+Cbp6xsT37amk3OccSRIm7h4PLz8mlmBOjCYthRKgghMekhICZROUNsvS0 iaCxqCdFWGy/OAbNgxKCy5eIen4XhfwPZLkhMTrVxQ1GWwGH9PdXXgAfY2aNG771 jV/wc2YDJ/FBWaEblYB0kEMkdzdoxJ5VddWRmuyDWo4WHcs1F2m2/Qmi0NNhgmJo CX5SRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=FtR+UgOOZLBiQrxLIVMV0q/xz8NJCgPfEh2OWV3jr gA=; b=Qkg0mF0LYwEWjenY/Ia5QGA0r6oLp5YZXj6Hz2TaraRoENC2nxYLZNBfg uBbhIQUA4dKPRBVQd/OboEDQgTnNJlfvEaYEXdLBqJ2nKGXxtkoT9I8CK6dl9Xak NcjKpd9D1XCvY1ZMs4XLKeBikLMvyS0kImERwTBY1/gtj03dEwuB8W8tNmHIvPfZ Gskl+PdCJiiBYYm9xyF8+2epbMGpwWT4cBEfdju+O+bLSXazgbsre0LfgehX/RKB TDVQcnsPx9QAGFPREvgR1gTyf4aDGBiKqFLBh9LIlqKgYX3spEaUg06vkpwTZvFy E8NbT9fRrVC8jtfOdkETRYRalhFYA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejuddguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuhffvfffkjghffgggtgfgsehtjedttddtreejnecuhfhrohhmpefkrghn ucfmvghnthcuoehrrghvvghnsehthhgvmhgrfidrnhgvtheqnecuggftrfgrthhtvghrnh epvddvvdfgleefhfelgfekvdejjefhvdetfeevueeggeefhfdujeegveejveejgfdunecu kfhppeehkedrjedrudelgedrkeejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrg hmpehmrghilhhfrhhomheprhgrvhgvnhesthhhvghmrgifrdhnvght X-ME-Proxy: Received: from mickey.themaw.net (58-7-194-87.dyn.iinet.net.au [58.7.194.87]) by mail.messagingengine.com (Postfix) with ESMTPA id E37A93280060; Wed, 17 Jun 2020 03:37:55 -0400 (EDT) Received: from mickey.themaw.net (localhost [127.0.0.1]) by mickey.themaw.net (Postfix) with ESMTP id 5D080A0314; Wed, 17 Jun 2020 15:37:53 +0800 (AWST) Subject: [PATCH v2 2/6] kernfs: move revalidate to be near lookup From: Ian Kent To: Greg Kroah-Hartman Cc: Tejun Heo , Stephen Rothwell , Andrew Morton , Al Viro , Rick Lindsley , David Howells , Miklos Szeredi , linux-fsdevel , Kernel Mailing List Date: Wed, 17 Jun 2020 15:37:53 +0800 Message-ID: <159237947334.89469.11409230524327917644.stgit@mickey.themaw.net> In-Reply-To: <159237905950.89469.6559073274338175600.stgit@mickey.themaw.net> References: <159237905950.89469.6559073274338175600.stgit@mickey.themaw.net> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the dentry operation kernfs_dop_revalidate() is grouped with dentry'ish functions it also has a strong afinity to the inode operation ->lookup(). And when path walk improvements are applied it will need to call kernfs_find_ns() so move it to be near kernfs_iop_lookup() to avoid the need for a forward declaration. There's no functional change from this patch. 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 d8213fc65eba..9b315f3b20ee 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -559,49 +559,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); - down_read(&kernfs_rwsem); - - /* 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; - - up_read(&kernfs_rwsem); - return 1; -out_bad: - up_read(&kernfs_rwsem); -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 @@ -1085,6 +1042,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); + down_read(&kernfs_rwsem); + + /* 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; + + up_read(&kernfs_rwsem); + return 1; +out_bad: + up_read(&kernfs_rwsem); +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)