[PATCH 2/3] VFS: rename lookup_map to dep_map

From: NeilBrown

Date: Fri Oct 02 2026 - 18:44:35 EST


From: NeilBrown <neil@xxxxxxxxxx>

lockdep has a number of macros which assume the lockdep_map is in a
field called "dep_map". If dentry.lookup_map is renamed to dep_map
these macros can be used.

In this patch we can now use might_lock(). In future
lockdep_set_class() will be used.

Fixes: 59492f9991dc ("VFS: add lockdep monitoring of DCACHE_PAR_LOOKUP lock.")
Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
---
fs/dcache.c | 15 +++++++--------
include/linux/dcache.h | 6 +++---
2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 7581ee2981d1..c8116c5805c0 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1958,7 +1958,7 @@ 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",
+ lockdep_init_map(&dentry->dep_map, "DCACHE_PAR_LOOKUP",
&sb->s_type->d_lookup_key, 0);

if (dentry->d_op && dentry->d_op->d_init) {
@@ -2040,7 +2040,7 @@ struct dentry *d_duplicate(struct dentry *dentry)
return ERR_PTR(-ENOMEM);

new->d_flags |= DCACHE_PAR_LOOKUP;
- lock_map_acquire_try(&new->lookup_map);
+ lock_map_acquire_try(&new->dep_map);
spin_lock(&parent->d_lock);
new->d_parent = dget_dlock(parent);
hlist_add_head(&new->d_sib, &parent->d_children);
@@ -2806,12 +2806,11 @@ static void d_wait_lookup(struct dentry *dentry)
{
if (likely(d_in_lookup(dentry))) {
/*
- * Tell lockdep we will wait for the lookup lock, after
- * dropping ->d_lock, but won't actually take it.
+ * Tell lockdep we may wait for the lookup lock, after
+ * dropping ->d_lock.
*/
spin_release(&dentry->d_lock.dep_map, _THIS_IP_);
- lock_map_acquire(&dentry->lookup_map);
- lock_map_release(&dentry->lookup_map);
+ might_lock(dentry);
spin_acquire(&dentry->d_lock.dep_map, 0, 1, _THIS_IP_);

dentry->d_flags |= DCACHE_LOOKUP_WAITERS;
@@ -2936,7 +2935,7 @@ struct dentry *__d_alloc_parallel(struct dentry *parent,
}
hlist_bl_add_head(&new->d_in_lookup_hash, b);
hlist_bl_unlock(b);
- lock_map_acquire_try(&new->lookup_map);
+ lock_map_acquire_try(&new->dep_map);
return new;
mismatch:
spin_unlock(&dentry->d_lock);
@@ -3035,7 +3034,7 @@ static void __d_lookup_unhash(struct dentry *dentry)
b = in_lookup_hash(dentry->d_parent, dentry->d_name.hash);
hlist_bl_lock(b);
dentry->d_flags &= ~DCACHE_PAR_LOOKUP;
- lock_map_release(&dentry->lookup_map);
+ lock_map_release(&dentry->dep_map);
__hlist_bl_del(&dentry->d_in_lookup_hash);
hlist_bl_unlock(b);
dentry->waiters = NULL;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index adf239f8205f..796282817181 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -117,7 +117,7 @@ struct dentry {
*/

/* lockdep tracking of DCACHE_PAR_LOOKUP locks */
- struct lockdep_map lookup_map;
+ struct lockdep_map dep_map;
struct list_head d_lru; /* LRU list */
struct hlist_node d_sib; /* child of parent list */
struct hlist_head d_children; /* our children */
@@ -571,7 +571,7 @@ unsigned long vfs_pressure_ratio(unsigned long val);
static inline void d_lookup_release(struct dentry *dentry)
{
if (d_in_lookup(dentry))
- lock_map_release(&dentry->lookup_map);
+ lock_map_release(&dentry->dep_map);
}

/**
@@ -585,7 +585,7 @@ static inline void d_lookup_release(struct dentry *dentry)
static inline void d_lookup_acquire(struct dentry *dentry)
{
if (d_in_lookup(dentry))
- lock_map_acquire_try(&dentry->lookup_map);
+ lock_map_acquire_try(&dentry->dep_map);
}

/**
--
2.50.0.107.gf914562f5916.dirty