mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
Pseudofs was leaking VFS cache entries badly due to its cache and use of
the wrong VOP descriptor. This misuse caused VFS-cached vnodes to be re-cached, resulting in the leak. This commit is an interim fix until DES has a chance to rework the code involved.
This commit is contained in:
parent
02f2c8a235
commit
08f3c74981
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=88234
@ -105,9 +105,11 @@ pfs_vncache_alloc(struct mount *mp, struct vnode **vpp,
|
||||
{
|
||||
struct pfs_vdata *pvd;
|
||||
int error;
|
||||
|
||||
/* see if the vnode is in the cache */
|
||||
/* XXX linear search... not very efficient */
|
||||
|
||||
/*
|
||||
* See if the vnode is in the cache.
|
||||
* XXX linear search is not very efficient.
|
||||
*/
|
||||
mtx_lock(&pfs_vncache_mutex);
|
||||
for (pvd = pfs_vncache; pvd; pvd = pvd->pvd_next) {
|
||||
if (pvd->pvd_pn == pn && pvd->pvd_pid == pid) {
|
||||
@ -115,6 +117,8 @@ pfs_vncache_alloc(struct mount *mp, struct vnode **vpp,
|
||||
++pfs_vncache_hits;
|
||||
*vpp = pvd->pvd_vnode;
|
||||
mtx_unlock(&pfs_vncache_mutex);
|
||||
/* XXX see comment at top of pfs_lookup() */
|
||||
cache_purge(*vpp);
|
||||
return (0);
|
||||
}
|
||||
/* XXX if this can happen, we're in trouble */
|
||||
@ -176,6 +180,8 @@ int
|
||||
pfs_vncache_free(struct vnode *vp)
|
||||
{
|
||||
struct pfs_vdata *pvd;
|
||||
|
||||
cache_purge(vp);
|
||||
|
||||
mtx_lock(&pfs_vncache_mutex);
|
||||
pvd = (struct pfs_vdata *)vp->v_data;
|
||||
|
@ -293,6 +293,15 @@ pfs_getextattr(struct vop_getextattr_args *va)
|
||||
|
||||
/*
|
||||
* Look up a file or directory
|
||||
*
|
||||
* XXX NOTE! pfs_lookup() has been hooked into vop_lookup_desc! This
|
||||
* will result in a lookup operation for a vnode which may already be
|
||||
* cached, therefore we have to be careful to purge the VFS cache when
|
||||
* reusing a vnode.
|
||||
*
|
||||
* This code will work, but is not really correct. Normally we would hook
|
||||
* vfs_cache_lookup() into vop_lookup_desc and hook pfs_lookup() into
|
||||
* vop_cachedlookup_desc.
|
||||
*/
|
||||
static int
|
||||
pfs_lookup(struct vop_lookup_args *va)
|
||||
@ -385,6 +394,9 @@ pfs_lookup(struct vop_lookup_args *va)
|
||||
error = pfs_vncache_alloc(vn->v_mount, vpp, pn, pid);
|
||||
if (error)
|
||||
PFS_RETURN (error);
|
||||
/*
|
||||
* XXX See comment at top of the routine.
|
||||
*/
|
||||
if (cnp->cn_flags & MAKEENTRY)
|
||||
cache_enter(vn, *vpp, cnp);
|
||||
PFS_RETURN (0);
|
||||
@ -693,7 +705,7 @@ static int
|
||||
pfs_reclaim(struct vop_reclaim_args *va)
|
||||
{
|
||||
PFS_TRACE((((struct pfs_vdata *)va->a_vp->v_data)->pvd_pn->pn_name));
|
||||
|
||||
|
||||
return (pfs_vncache_free(va->a_vp));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user