From: NeilBrown <neilb@ownmail.net>
To: Miklos Szeredi <miklos@szeredi.hu>,
Amir Goldstein <amir73il@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
"Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Cc: Jeff Layton <jlayton@kernel.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-unionfs@vger.kernel.org
Subject: [PATCH 3/3] ovl: provide private lockdep class for dentry->dep_map
Date: Sat, 3 Oct 2026 08:35:44 +1000 [thread overview]
Message-ID: <20261002223746.3248726-4-neilb@ownmail.net> (raw)
In-Reply-To: <20261002223746.3248726-1-neilb@ownmail.net>
From: NeilBrown <neil@brown.name>
Now that d_alloc_parallel() locking is tracked by lockdep, ovl needs to
take care that it doesn't trigger on deliberate recursion into
subordinate filesystems. As ovl can stack over itself, the use
of the per-file_system_type d_lookup_key is not enough.
So provide a .d_init() function to update the map as it already done for
i_rwsem and ovl_inode.lock.
Reported-and-tested-by: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Link: https://lore.kernel.org/all/e3772a51-eabc-4c31-b73d-f3187bf1b3b2@intel.com/
Fixes: 59492f9991dc ("VFS: add lockdep monitoring of DCACHE_PAR_LOOKUP lock.")
Signed-off-by: NeilBrown <neil@brown.name>
---
fs/overlayfs/inode.c | 1 -
fs/overlayfs/overlayfs.h | 2 ++
fs/overlayfs/super.c | 19 +++++++++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 401cb8c75520..bf40198c8b8a 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -816,7 +816,6 @@ static const struct address_space_operations ovl_aops = {
* - OVL_I(inode)->lock (ovl_inode_lock[1])
* - upper_mnt->mnt_sb->s_writers (ovl_want_write[0])
*/
-#define OVL_MAX_NESTING FILESYSTEM_MAX_STACK_DEPTH
static inline void ovl_lockdep_annotate_inode_mutex_key(struct inode *inode)
{
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index e0d8c6152e9f..64cbe4c4bd3e 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -16,6 +16,8 @@
#undef pr_fmt
#define pr_fmt(fmt) "overlayfs: " fmt
+#define OVL_MAX_NESTING FILESYSTEM_MAX_STACK_DEPTH
+
enum ovl_path_type {
__OVL_PATH_UPPER = (1 << 0),
__OVL_PATH_MERGE = (1 << 1),
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index e487597337e8..08147799e47c 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -163,10 +163,28 @@ static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
return ovl_dentry_revalidate_common(dentry, flags, true);
}
+#ifdef CONFIG_LOCKDEP
+static int ovl_dentry_init(struct dentry *dentry)
+{
+ static struct lock_class_key ovl_d_lock_key[OVL_MAX_NESTING];
+ int depth = dentry->d_sb->s_stack_depth - 1;
+
+ if (WARN_ON_ONCE(depth < 0 || depth >= OVL_MAX_NESTING))
+ depth = 0;
+
+ lockdep_set_class(dentry, &ovl_d_lock_key[depth]);
+
+ return 0;
+}
+#else
+#define ovl_dentry_init NULL
+#endif
+
static const struct dentry_operations ovl_dentry_operations = {
.d_real = ovl_d_real,
.d_revalidate = ovl_dentry_revalidate,
.d_weak_revalidate = ovl_dentry_weak_revalidate,
+ .d_init = ovl_dentry_init,
};
#if IS_ENABLED(CONFIG_UNICODE)
@@ -176,6 +194,7 @@ static const struct dentry_operations ovl_dentry_ci_operations = {
.d_weak_revalidate = ovl_dentry_weak_revalidate,
.d_hash = generic_ci_d_hash,
.d_compare = generic_ci_d_compare,
+ .d_init = ovl_dentry_init,
};
#endif
--
2.50.0.107.gf914562f5916.dirty
next prev parent reply other threads:[~2026-10-02 22:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 22:35 [PATCH 0/3] Fixes for dentry lockdep tracking on stacking filesystems NeilBrown
2026-10-02 22:35 ` [PATCH 1/3] VFS: per-fs-type lockdep key for dentry in-lookup locking NeilBrown
2026-10-02 22:35 ` [PATCH 2/3] VFS: rename lookup_map to dep_map NeilBrown
2026-10-02 22:35 ` NeilBrown [this message]
2026-10-03 12:52 ` [PATCH 3/3] ovl: provide private lockdep class for dentry->dep_map Amir Goldstein
2026-10-16 5:47 ` Borah, Chaitanya Kumar
2026-10-16 6:57 ` [PATCH 0/3] Fixes for dentry lockdep tracking on stacking filesystems Amir Goldstein
2026-10-16 8:08 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261002223746.3248726-4-neilb@ownmail.net \
--to=neilb@ownmail.net \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=chaitanya.kumar.borah@intel.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neil@brown.name \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®