cache: perform reverse lookup using v_cache_dd if possible

Tested by:	pho
This commit is contained in:
Mateusz Guzik 2020-08-24 08:55:55 +00:00
parent ce575cd0e2
commit f0696c5e4b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364632

View File

@ -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 *buf, size_t *buflen)
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) {