[PATCH] fs: only assert on LOOKUP_RCU when built with CONFIG_DEBUG_VFS

From: Mateusz Guzik
Date: Mon Dec 29 2025 - 08:08:35 EST


Calls to the 2 modified routines are explicitly gated with checks for
the flag, so there is no use for this in production kernels.

Signed-off-by: Mateusz Guzik <mjguzik@xxxxxxxxx>
---
fs/namei.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index f7a8b5b000c2..9c5a372a86f6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -879,7 +879,7 @@ static bool try_to_unlazy(struct nameidata *nd)
{
struct dentry *parent = nd->path.dentry;

- BUG_ON(!(nd->flags & LOOKUP_RCU));
+ VFS_BUG_ON(!(nd->flags & LOOKUP_RCU));

if (unlikely(nd->flags & LOOKUP_CACHED)) {
drop_links(nd);
@@ -919,7 +919,8 @@ static bool try_to_unlazy(struct nameidata *nd)
static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry)
{
int res;
- BUG_ON(!(nd->flags & LOOKUP_RCU));
+
+ VFS_BUG_ON(!(nd->flags & LOOKUP_RCU));

if (unlikely(nd->flags & LOOKUP_CACHED)) {
drop_links(nd);
--
2.48.1