aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-12-28 09:25:01 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-01-01 00:10:43 +0000
commit6fe7de1a250bb497ca1a3e1d979ae21c2149c2ea (patch)
treeb813315e6fe8d4de93863e8485516b56e392f3e5
parente17e01bd0e4a528fff69bff8faf7045d4d619aae (diff)
downloadsrc-6fe7de1a250bb497ca1a3e1d979ae21c2149c2ea.tar.gz
src-6fe7de1a250bb497ca1a3e1d979ae21c2149c2ea.zip
cache: refactor cache_fpl_handle_root to fit the rest of the code better
Tested by: pho
-rw-r--r--sys/kern/vfs_cache.c55
1 files 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.
@@ -3614,6 +3589,34 @@ struct cache_fpl {
};
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) {