[PATCH 1/3] VFS: per-fs-type lockdep key for dentry in-lookup locking
From: NeilBrown
Date: Fri Oct 02 2026 - 18:44:13 EST
From: NeilBrown <neil@xxxxxxxxxx>
Stacked file-systems might call d_alloc_parallel() in another
file-system while holding an in-lookup dentry is this filesystem. In
order for lockdep not to report that, we give each file-system-type a
different lockdep key for in-lookup locking.
This matches what is already done for lockdep tracking of i_rwsem.
Fixes: 59492f9991dc ("VFS: add lockdep monitoring of DCACHE_PAR_LOOKUP lock.")
Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
---
fs/dcache.c | 4 ++--
include/linux/fs.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 83790c7a4dee..7581ee2981d1 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1901,7 +1901,6 @@ EXPORT_SYMBOL(d_invalidate);
static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
{
- static struct lock_class_key __lookup_key;
struct dentry *dentry;
char *dname;
int err;
@@ -1959,7 +1958,8 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
dentry->waiters = NULL;
INIT_HLIST_NODE(&dentry->d_sib);
- lockdep_init_map(&dentry->lookup_map, "DCACHE_PAR_LOOKUP", &__lookup_key, 0);
+ lockdep_init_map(&dentry->lookup_map, "DCACHE_PAR_LOOKUP",
+ &sb->s_type->d_lookup_key, 0);
if (dentry->d_op && dentry->d_op->d_init) {
err = dentry->d_op->d_init(dentry);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f9d1e05e8ae6..0a5bdc71a4a4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2313,6 +2313,8 @@ struct file_system_type {
struct lock_class_key i_mutex_key;
struct lock_class_key invalidate_lock_key;
struct lock_class_key i_mutex_dir_key;
+
+ struct lock_class_key d_lookup_key;
};
#define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME)
base-commit: 3879f51857325da9bf3cfb073280257cd16ae067
--
2.50.0.107.gf914562f5916.dirty