svn commit: r308261 - head/sys/vm

Alan Cox alc at FreeBSD.org
Thu Nov 3 16:44:57 UTC 2016


Author: alc
Date: Thu Nov  3 16:44:55 2016
New Revision: 308261
URL: https://svnweb.freebsd.org/changeset/base/308261

Log:
  In vm_fault()'s loop over the shadow chain, move a comment describing our
  invariants to a better place.  Also, add two comments concerning the
  relationship between the map and vnode locks.
  
  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	Thu Nov  3 15:04:16 2016	(r308260)
+++ head/sys/vm/vm_fault.c	Thu Nov  3 16:44:55 2016	(r308261)
@@ -564,6 +564,14 @@ fast_failed:
 
 readrest:
 		/*
+		 * At this point, we have either allocated a new page or found
+		 * an existing page that is only partially valid.
+		 *
+		 * We hold a reference on the current object and the page is
+		 * exclusive busied.
+		 */
+
+		/*
 		 * If the pager for the current object might have the page,
 		 * then determine the number of additional pages to read and
 		 * potentially reprioritize previously read pages for earlier
@@ -632,18 +640,23 @@ readrest:
 		 */
 		if (fs.object->type != OBJT_DEFAULT) {
 			/*
-			 * We have either allocated a new page or found an
-			 * existing page that is only partially valid.  We
-			 * hold a reference on fs.object and the page is
-			 * exclusive busied.
+			 * Release the map lock before locking the vnode or
+			 * sleeping in the pager.  (If the current object has
+			 * a shadow, then an earlier iteration of this loop
+			 * may have already unlocked the map.)
 			 */
 			unlock_map(&fs);
 
 			if (fs.object->type == OBJT_VNODE &&
 			    (vp = fs.object->handle) != fs.vp) {
+				/*
+				 * Perform an unlock in case the desired vnode
+				 * changed while the map was unlocked during a
+				 * retry.
+				 */
 				unlock_vp(&fs);
-				locked = VOP_ISLOCKED(vp);
 
+				locked = VOP_ISLOCKED(vp);
 				if (locked != LK_EXCLUSIVE)
 					locked = LK_SHARED;
 


More information about the svn-src-head mailing list