[v3,1/4] kernfs: move revalidate to be near lookup
diff mbox series

Message ID 161793089488.10062.4398328199044761298.stgit@mickey.themaw.net
State New, archived
Headers show
Series
  • kernfs: proposed locking and concurrency improvement
Related show

Commit Message

Ian Kent April 9, 2021, 1:14 a.m. UTC
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.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/kernfs/dir.c |   86 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 43 insertions(+), 43 deletions(-)

Comments

kernel test robot April 9, 2021, 3:39 a.m. UTC | #1
Hi Ian,

I love your patch! Yet something to improve:

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v5.12-rc6 next-20210408]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ian-Kent/kernfs-proposed-locking-and-concurrency-improvement/20210409-091821
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git c2f3f755f5c717f3621b33ef06d974b9cec4a104
config: arm-defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/a3608518cc551301c1c33dbf6976c360ea82a95c
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ian-Kent/kernfs-proposed-locking-and-concurrency-improvement/20210409-091821
        git checkout a3608518cc551301c1c33dbf6976c360ea82a95c
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

Note: the linux-review/Ian-Kent/kernfs-proposed-locking-and-concurrency-improvement/20210409-091821 HEAD b2217b0abf0a4518541559173ff04138a6e4f083 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   fs/kernfs/dir.c: In function 'kernfs_dop_revalidate':
>> fs/kernfs/dir.c:1048:7: error: implicit declaration of function 'kernfs_active_read'; did you mean 'kernfs_active'? [-Werror=implicit-function-declaration]
    1048 |  if (!kernfs_active_read(kn))
         |       ^~~~~~~~~~~~~~~~~~
         |       kernfs_active
   cc1: some warnings being treated as errors


vim +1048 fs/kernfs/dir.c

  1032	
  1033	static int kernfs_dop_revalidate(struct dentry *dentry, unsigned int flags)
  1034	{
  1035		struct kernfs_node *kn;
  1036	
  1037		if (flags & LOOKUP_RCU)
  1038			return -ECHILD;
  1039	
  1040		/* Always perform fresh lookup for negatives */
  1041		if (d_really_is_negative(dentry))
  1042			goto out_bad_unlocked;
  1043	
  1044		kn = kernfs_dentry_node(dentry);
  1045		mutex_lock(&kernfs_mutex);
  1046	
  1047		/* The kernfs node has been deactivated */
> 1048		if (!kernfs_active_read(kn))
  1049			goto out_bad;
  1050	
  1051		/* The kernfs node has been moved? */
  1052		if (kernfs_dentry_node(dentry->d_parent) != kn->parent)
  1053			goto out_bad;
  1054	
  1055		/* The kernfs node has been renamed */
  1056		if (strcmp(dentry->d_name.name, kn->name) != 0)
  1057			goto out_bad;
  1058	
  1059		/* The kernfs node has been moved to a different namespace */
  1060		if (kn->parent && kernfs_ns_enabled(kn->parent) &&
  1061		    kernfs_info(dentry->d_sb)->ns != kn->ns)
  1062			goto out_bad;
  1063	
  1064		mutex_unlock(&kernfs_mutex);
  1065		return 1;
  1066	out_bad:
  1067		mutex_unlock(&kernfs_mutex);
  1068	out_bad_unlocked:
  1069		return 0;
  1070	}
  1071	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Patch
diff mbox series

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)