git: 6fe7de1a250b - main - cache: refactor cache_fpl_handle_root to fit the rest of the code better

Mateusz Guzik mjg at FreeBSD.org
Fri Jan 1 00:11:53 UTC 2021


The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=6fe7de1a250bb497ca1a3e1d979ae21c2149c2ea

commit 6fe7de1a250bb497ca1a3e1d979ae21c2149c2ea
Author:     Mateusz Guzik <mjg at FreeBSD.org>
AuthorDate: 2020-12-28 09:25:01 +0000
Commit:     Mateusz Guzik <mjg at FreeBSD.org>
CommitDate: 2021-01-01 00:10:43 +0000

    cache: refactor cache_fpl_handle_root to fit the rest of the code better
    
    Tested by:      pho
---
 sys/kern/vfs_cache.c | 55 +++++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 22a5b54b2805..49fabc47884d 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -3562,31 +3562,6 @@ SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_lookup, CTLFLAG_RW,
 
 #define CACHE_FPL_FAILED	-2020
 
-static void
-cache_fpl_cleanup_cnp(struct componentname *cnp)
-{
-
-	uma_zfree(namei_zone, cnp->cn_pnbuf);
-#ifdef DIAGNOSTIC
-	cnp->cn_pnbuf = NULL;
-	cnp->cn_nameptr = NULL;
-#endif
-}
-
-static void
-cache_fpl_handle_root(struct nameidata *ndp, struct vnode **dpp)
-{
-	struct componentname *cnp;
-
-	cnp = &ndp->ni_cnd;
-	while (*(cnp->cn_nameptr) == '/') {
-		cnp->cn_nameptr++;
-		ndp->ni_pathlen--;
-	}
-
-	*dpp = ndp->ni_rootdir;
-}
-
 /*
  * Components of nameidata (or objects it can point to) which may
  * need restoring in case fast path lookup fails.
@@ -3613,6 +3588,34 @@ struct cache_fpl {
 	bool fsearch;
 };
 
+static void
+cache_fpl_cleanup_cnp(struct componentname *cnp)
+{
+
+	uma_zfree(namei_zone, cnp->cn_pnbuf);
+#ifdef DIAGNOSTIC
+	cnp->cn_pnbuf = NULL;
+	cnp->cn_nameptr = NULL;
+#endif
+}
+
+static struct vnode *
+cache_fpl_handle_root(struct cache_fpl *fpl)
+{
+	struct nameidata *ndp;
+	struct componentname *cnp;
+
+	ndp = fpl->ndp;
+	cnp = fpl->cnp;
+
+	while (*(cnp->cn_nameptr) == '/') {
+		cnp->cn_nameptr++;
+		ndp->ni_pathlen--;
+	}
+
+	return (ndp->ni_rootdir);
+}
+
 static void
 cache_fpl_checkpoint(struct cache_fpl *fpl, struct nameidata_saved *snd)
 {
@@ -5174,7 +5177,7 @@ cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
 	cnp = fpl.cnp;
 	cnp->cn_nameptr = cnp->cn_pnbuf;
 	if (cnp->cn_pnbuf[0] == '/') {
-		cache_fpl_handle_root(ndp, &dvp);
+		dvp = cache_fpl_handle_root(&fpl);
 		ndp->ni_resflags |= NIRES_ABS;
 	} else {
 		if (ndp->ni_dirfd == AT_FDCWD) {


More information about the dev-commits-src-all mailing list