Date: Fri, 20 Aug 2021 17:52:30 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: dbc689cdef0c - main - vfs: use vn_lock_pair to avoid establishing an ordering on mount Message-ID: <202108201752.17KHqUVc084605@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=dbc689cdef0cc8ff11171642cdcf107dfbc3fb41 commit dbc689cdef0cc8ff11171642cdcf107dfbc3fb41 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-08-18 21:14:16 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-08-20 17:52:24 +0000 vfs: use vn_lock_pair to avoid establishing an ordering on mount This fixes some of the LORs seen on mount/unmount. Complete fix will require taking care of unmount as well. Reviewed by: kib Tested by: pho (previous version) Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31611 --- sys/kern/vfs_mount.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 3c546392b213..92e70e45d46e 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1191,19 +1191,28 @@ vfs_domount_first( mp->mnt_kern_flag &= ~MNTK_ASYNC; MNT_IUNLOCK(mp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - cache_purge(vp); VI_LOCK(vp); - vp->v_iflag &= ~VI_MOUNT; + cache_purge(vp); vn_irflag_set_locked(vp, VIRF_MOUNTPOINT); vp->v_mountedhere = mp; VI_UNLOCK(vp); + + /* + * 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); + + VI_LOCK(vp); + vp->v_iflag &= ~VI_MOUNT; + VI_UNLOCK(vp); /* Place the new filesystem at the end of the mount list. */ mtx_lock(&mountlist_mtx); 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108201752.17KHqUVc084605>