From owner-svn-src-stable-7@FreeBSD.ORG Tue Oct 11 14:05:40 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5AB08106564A; Tue, 11 Oct 2011 14:05:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 309768FC19; Tue, 11 Oct 2011 14:05:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9BE5ekN018638; Tue, 11 Oct 2011 14:05:40 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9BE5ec0018636; Tue, 11 Oct 2011 14:05:40 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201110111405.p9BE5ec0018636@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 11 Oct 2011 14:05:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226259 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2011 14:05:40 -0000 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,