Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2020 08:55:56 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364632 - head/sys/kern
Message-ID:  <202008240855.07O8tup1090590@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Mon Aug 24 08:55:55 2020
New Revision: 364632
URL: https://svnweb.freebsd.org/changeset/base/364632

Log:
  cache: perform reverse lookup using v_cache_dd if possible
  
  Tested by:	pho

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Mon Aug 24 08:55:04 2020	(r364631)
+++ head/sys/kern/vfs_cache.c	Mon Aug 24 08:55:55 2020	(r364632)
@@ -2572,6 +2572,19 @@ vn_fullpath_global(struct thread *td, struct vnode *vn
 	return (error);
 }
 
+static struct namecache *
+vn_dd_from_dst(struct vnode *vp)
+{
+	struct namecache *ncp;
+
+	cache_assert_vnode_locked(vp);
+	TAILQ_FOREACH(ncp, &vp->v_cache_dst, nc_dst) {
+		if ((ncp->nc_flag & NCF_ISDOTDOT) == 0)
+			return (ncp);
+	}
+	return (NULL);
+}
+
 int
 vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, size_t *buflen)
 {
@@ -2582,9 +2595,13 @@ vn_vptocnp(struct vnode **vp, struct ucred *cred, char
 
 	vlp = VP2VNODELOCK(*vp);
 	mtx_lock(vlp);
-	TAILQ_FOREACH(ncp, &((*vp)->v_cache_dst), nc_dst) {
-		if ((ncp->nc_flag & NCF_ISDOTDOT) == 0)
-			break;
+	ncp = (*vp)->v_cache_dd;
+	if (ncp != NULL && (ncp->nc_flag & NCF_ISDOTDOT) == 0) {
+		KASSERT(ncp == vn_dd_from_dst(*vp),
+		    ("%s: mismatch for dd entry (%p != %p)", __func__,
+		    ncp, vn_dd_from_dst(*vp)));
+	} else {
+		ncp = vn_dd_from_dst(*vp);
 	}
 	if (ncp != NULL) {
 		if (*buflen < ncp->nc_nlen) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008240855.07O8tup1090590>