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 @@ -1191,7 +1191,14 @@ mp->mnt_kern_flag &= ~MNTK_ASYNC; MNT_IUNLOCK(mp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + /* + * We need to lock both vnodes. + * + * Use vn_lock_pair to avoid establishing an ordering between vnodes + * from different filesystems. + */ + vn_lock_pair(vp, false, newdp, false); + cache_purge(vp); VI_LOCK(vp); vp->v_iflag &= ~VI_MOUNT; @@ -1203,7 +1210,6 @@ TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mtx_unlock(&mountlist_mtx); vfs_event_signal(NULL, VQ_MOUNT, 0); - vn_lock(newdp, LK_EXCLUSIVE | LK_RETRY); VOP_UNLOCK(vp); EVENTHANDLER_DIRECT_INVOKE(vfs_mounted, mp, newdp, td); VOP_UNLOCK(newdp);