Date: Tue, 11 Oct 2011 14:05:40 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r226259 - stable/7/sys/kern Message-ID: <201110111405.p9BE5ec0018636@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue Oct 11 14:05:39 2011 New Revision: 226259 URL: http://svn.freebsd.org/changeset/base/226259 Log: MFC r226022: Move parts of the commit log for r166167, where Tor explained the interaction between vnode locks and vfs_busy(), into comment. Comment is slightly edited to better fit into RELENG_7 reality. Modified: stable/7/sys/kern/vfs_subr.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Tue Oct 11 14:03:18 2011 (r226258) +++ stable/7/sys/kern/vfs_subr.c Tue Oct 11 14:05:39 2011 (r226259) @@ -335,6 +335,37 @@ SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_FIRST, /* * Mark a mount point as busy. Used to synchronize access and to delay * unmounting. Interlock is not released on failure. + * + * vfs_busy() only sleeps if the unmount is active on the mount point. + * For a mountpoint mp, vfs_busy-enforced lock is before lock of any + * vnode belonging to mp. + * + * Lookup uses vfs_busy() to traverse mount points. + * root fs var fs + * / vnode lock A / vnode lock (/var) D + * /var vnode lock B /log vnode lock(/var/log) E + * vfs_busy lock C vfs_busy lock F + * + * Within each file system, the lock order is C->A->B and F->D->E. + * + * When traversing across mounts, the system follows that lock order: + * + * C->A->B + * | + * +->F->D->E + * + * The lookup() process for namei("/var") illustrates the process: + * VOP_LOOKUP() obtains B while A is held + * vfs_busy() obtains a shared lock on F while A and B are held + * vput() releases lock on B + * vput() releases lock on A + * VFS_ROOT() obtains lock on D while shared lock on F is held + * vfs_unbusy() releases shared lock on F + * vn_lock() obtains lock on deadfs vnode vp_crossmp instead of A. + * Attempt to lock A (instead of vp_crossmp) while D is held would + * violate the global order, causing deadlocks. + * + * dounmount() locks B while F is drained. */ int vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110111405.p9BE5ec0018636>