svn commit: r308174 - head/sys/vm

Alan Cox alc at FreeBSD.org
Tue Nov 1 17:11:12 UTC 2016


Author: alc
Date: Tue Nov  1 17:11:10 2016
New Revision: 308174
URL: https://svnweb.freebsd.org/changeset/base/308174

Log:
  Move and revise a comment about the relation between the object's paging-
  in-progress count and the vnode.  Prior to r188331, we always acquired
  the vnode lock before incrementing the object's paging-in-progress count.
  Now, we increment it before attempting to acquire the vnode lock with
  LK_NOWAIT, but we never sleep acquiring the vnode lock while we have the
  count incremented.
  
  Reviewed by:	kib
  MFC after:	3 days

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==============================================================================
--- head/sys/vm/vm_fault.c	Tue Nov  1 16:03:31 2016	(r308173)
+++ head/sys/vm/vm_fault.c	Tue Nov  1 17:11:10 2016	(r308174)
@@ -420,8 +420,7 @@ fast_failed:
 	 * they will stay around as well.
 	 *
 	 * Bump the paging-in-progress count to prevent size changes (e.g. 
-	 * truncation operations) during I/O.  This must be done after
-	 * obtaining the vnode lock in order to avoid possible deadlocks.
+	 * truncation operations) during I/O.
 	 */
 	vm_object_reference_locked(fs.first_object);
 	vm_object_pip_add(fs.first_object, 1);
@@ -647,7 +646,13 @@ readrest:
 
 				if (locked != LK_EXCLUSIVE)
 					locked = LK_SHARED;
-				/* Do not sleep for vnode lock while fs.m is busy */
+
+				/*
+				 * We must not sleep acquiring the vnode lock
+				 * while we have the page exclusive busied or
+				 * the object's paging-in-progress count
+				 * incremented.  Otherwise, we could deadlock.
+				 */
 				error = vget(vp, locked | LK_CANRECURSE |
 				    LK_NOWAIT, curthread);
 				if (error != 0) {


More information about the svn-src-head mailing list