git: 2ffee9aef7c2 - main - vfs_lookup: split NDRESTART

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 04 Jul 2025 15:23:53 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ffee9aef7c272d631dc072f7cfdd978c01c7dc8

commit 2ffee9aef7c272d631dc072f7cfdd978c01c7dc8
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-06-15 07:51:48 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-07-04 15:23:42 +0000

    vfs_lookup: split NDRESTART
    
    to have a convenient way to clear internal and result flags without
    marking ndp as restarting.
    
    Reviewed by:    markj, olce
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D50648
---
 sys/kern/vfs_lookup.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 86c7bdaa02c0..499325a3a406 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -74,15 +74,21 @@ static void NDVALIDATE_impl(struct nameidata *, int);
 #define NDVALIDATE(ndp)
 #endif
 
+/*
+ * Reset ndp to its original state.
+ */
+#define	NDRESET(ndp) do {						\
+	NDREINIT_DBG(ndp);						\
+	ndp->ni_resflags = 0;						\
+	ndp->ni_cnd.cn_flags &= ~NAMEI_INTERNAL_FLAGS;			\
+} while (0)
 /*
  * Prepare namei() to restart. Reset components to its original state and set
  * ISRESTARTED flag which signals the underlying lookup code to change the root
  * from ABI root to actual root and prevents a further restarts.
  */
 #define	NDRESTART(ndp) do {						\
-	NDREINIT_DBG(ndp);						\
-	ndp->ni_resflags = 0;						\
-	ndp->ni_cnd.cn_flags &= ~NAMEI_INTERNAL_FLAGS;			\
+	NDRESET(ndp);						\
 	ndp->ni_cnd.cn_flags |= ISRESTARTED;				\
 } while (0)