git: 807c4914a54b - stable/13 - cache: remove NOCACHE handling from cache_fplookup_noentry

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sat, 05 Mar 2022 19:56:54 UTC
The branch stable/13 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=807c4914a54b67bdf088f5d2ae6184f11d4f5f47

commit 807c4914a54b67bdf088f5d2ae6184f11d4f5f47
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-02-09 20:39:28 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-03-05 19:53:46 +0000

    cache: remove NOCACHE handling from cache_fplookup_noentry
    
    It was copy-pasted from locked lookup. As LOOKUP operation cannot have
    the flag set it was always ending up setting MAKEENTRY.
    
    (cherry picked from commit 611470a51560db61488b2d864176b8076eb5a65c)
---
 sys/kern/vfs_cache.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index ef4e33308472..780b5003749b 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4830,7 +4830,6 @@ cache_fplookup_noentry(struct cache_fpl *fpl)
 	struct vnode *dvp, *tvp;
 	seqc_t dvp_seqc;
 	int error;
-	bool docache;
 
 	ndp = fpl->ndp;
 	cnp = fpl->cnp;
@@ -4839,6 +4838,8 @@ cache_fplookup_noentry(struct cache_fpl *fpl)
 
 	MPASS((cnp->cn_flags & MAKEENTRY) == 0);
 	MPASS((cnp->cn_flags & ISDOTDOT) == 0);
+	if (cnp->cn_nameiop == LOOKUP)
+		MPASS((cnp->cn_flags & NOCACHE) == 0);
 	MPASS(!cache_fpl_isdotdot(cnp));
 
 	/*
@@ -4915,10 +4916,7 @@ cache_fplookup_noentry(struct cache_fpl *fpl)
 	/*
 	 * TODO: provide variants which don't require locking either vnode.
 	 */
-	cnp->cn_flags |= ISLASTCN;
-	docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE;
-	if (docache)
-		cnp->cn_flags |= MAKEENTRY;
+	cnp->cn_flags |= ISLASTCN | MAKEENTRY;
 	cnp->cn_lkflags = LK_SHARED;
 	if ((cnp->cn_flags & LOCKSHARED) == 0) {
 		cnp->cn_lkflags = LK_EXCLUSIVE;