Limit scope of the optimization in r306608 to dounmount() caller only.

Other uses of cache_purgevfs() do rely on the cache purge for correct
operations, when paths are invalidated without unmount.

Reported and tested by:	jkim
Discussed with:	mjg
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Konstantin Belousov 2016-10-07 11:38:28 +00:00
parent 6f98c83306
commit f71d08566c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306803
5 changed files with 8 additions and 8 deletions

View File

@ -1843,7 +1843,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
*/
(void) dnlc_purge_vfsp(zfsvfs->z_parent->z_vfs, 0);
#ifdef FREEBSD_NAMECACHE
cache_purgevfs(zfsvfs->z_parent->z_vfs);
cache_purgevfs(zfsvfs->z_parent->z_vfs, true);
#endif
}

View File

@ -1756,7 +1756,7 @@ cache_purge_negative(struct vnode *vp)
* Flush all entries referencing a particular filesystem.
*/
void
cache_purgevfs(struct mount *mp)
cache_purgevfs(struct mount *mp, bool force)
{
TAILQ_HEAD(, namecache) ncps;
struct mtx *vlp1, *vlp2;
@ -1768,7 +1768,7 @@ cache_purgevfs(struct mount *mp)
/* Scan hash tables for applicable entries */
SDT_PROBE1(vfs, namecache, purgevfs, done, mp);
if (mp->mnt_nvnodelistsize <= ncpurgeminvnodes)
if (!force && mp->mnt_nvnodelistsize <= ncpurgeminvnodes)
return;
TAILQ_INIT(&ncps);
n_nchash = nchash + 1;

View File

@ -1352,7 +1352,7 @@ dounmount(struct mount *mp, int flags, struct thread *td)
mp->mnt_flag &= ~MNT_ASYNC;
mp->mnt_kern_flag &= ~MNTK_ASYNC;
MNT_IUNLOCK(mp);
cache_purgevfs(mp); /* remove cache entries for this file sys */
cache_purgevfs(mp, false); /* remove cache entries for this file sys */
vfs_deallocate_syncvnode(mp);
/*
* For forced unmounts, move process cdir/rdir refs on the fs root

View File

@ -298,9 +298,9 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
TAILQ_INSERT_TAIL(&mountlist, mpdevfs, mnt_list);
mtx_unlock(&mountlist_mtx);
cache_purgevfs(mporoot);
cache_purgevfs(mporoot, true);
if (mporoot != mpdevfs)
cache_purgevfs(mpdevfs);
cache_purgevfs(mpdevfs, true);
VFS_ROOT(mporoot, LK_EXCLUSIVE, &vporoot);
@ -315,7 +315,7 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
/* Set up the new rootvnode, and purge the cache */
mpnroot->mnt_vnodecovered = NULL;
set_rootvnode();
cache_purgevfs(rootvnode->v_mount);
cache_purgevfs(rootvnode->v_mount, true);
if (mporoot != mpdevfs) {
/* Remount old root under /.mount or /mnt */

View File

@ -608,7 +608,7 @@ int cache_lookup(struct vnode *dvp, struct vnode **vpp,
struct componentname *cnp, struct timespec *tsp, int *ticksp);
void cache_purge(struct vnode *vp);
void cache_purge_negative(struct vnode *vp);
void cache_purgevfs(struct mount *mp);
void cache_purgevfs(struct mount *mp, bool force);
int change_dir(struct vnode *vp, struct thread *td);
void cvtstat(struct stat *st, struct ostat *ost);
void cvtnstat(struct stat *sb, struct nstat *nsb);