vfs_domount(): ensure that v_mountedhere and VIRF_MOUNTPOINT are set under the vnode lock

Fixes:	f7833196bd
Reported and tested by:	pho
Reviewed by:	jah, markj (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37198
This commit is contained in:
Konstantin Belousov 2022-10-27 23:22:43 +03:00
parent 8b221ca631
commit 6b69465efb

View File

@ -1201,10 +1201,16 @@ vfs_domount_first(
mp->mnt_kern_flag &= ~MNTK_ASYNC;
MNT_IUNLOCK(mp);
/*
* VIRF_MOUNTPOINT and v_mountedhere need to be set under the
* vp lock to satisfy vfs_lookup() requirements.
*/
VOP_LOCK(vp, LK_EXCLUSIVE | LK_RETRY);
VI_LOCK(vp);
vn_irflag_set_locked(vp, VIRF_MOUNTPOINT);
vp->v_mountedhere = mp;
VI_UNLOCK(vp);
VOP_UNLOCK(vp);
cache_purge(vp);
/*