diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1259,6 +1259,12 @@ * if so find the root of the mounted filesystem. */ do { + /* + * Ensure that the v_mounthere update from + * vfs_domount() is visible if we saw the + * VIRF_MOUNTPOINT flag. + */ + atomic_thread_fence_acq(); mp = dp->v_mountedhere; KASSERT(mp != NULL, ("%s: NULL mountpoint for VIRF_MOUNTPOINT vnode", __func__)); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1202,8 +1202,9 @@ MNT_IUNLOCK(mp); VI_LOCK(vp); - vn_irflag_set_locked(vp, VIRF_MOUNTPOINT); vp->v_mountedhere = mp; + atomic_thread_fence_rel(); /* see vfs_lookup() */ + vn_irflag_set_locked(vp, VIRF_MOUNTPOINT); VI_UNLOCK(vp); cache_purge(vp);