svn commit: r254947 - stable/9/sys/kern

Konstantin Belousov kib at FreeBSD.org
Tue Aug 27 03:11:50 UTC 2013


Author: kib
Date: Tue Aug 27 03:11:49 2013
New Revision: 254947
URL: http://svnweb.freebsd.org/changeset/base/254947

Log:
  Partial MFC of r253927 (by attilio):
  Remove unnecessary soft busy of the page before to do vn_rdwr() in
  kern_sendfile() which is unnecessary.
  
  MFC note:
  NFS implementation of VOP_READ() sometimes upgrades the vnode lock,
  which causes drop of the shared lock and sleep for exclusive.  As
  result, busying of the page before the call to vn_rdwr() makes NFS
  code to wait for vnode lock while page is busy, which contradicts the
  proper order of vnode lock -> busy.
  
  The r250027, merged as part of r250907, started calling vm_page_grab()
  under the vnode lock.  The page grab waits for the page busy state to
  drain, which makes the parallel sendfile(2) invocations on the same
  vnode vulnerable to the LOR described above.
  
  Note that r250027 only exposed the problem, which might be caused by
  other means as well, e.g. by parallel sendfile(2) and truncate(2).
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/9/sys/kern/uipc_syscalls.c

Modified: stable/9/sys/kern/uipc_syscalls.c
==============================================================================
--- stable/9/sys/kern/uipc_syscalls.c	Tue Aug 27 01:40:13 2013	(r254946)
+++ stable/9/sys/kern/uipc_syscalls.c	Tue Aug 27 03:11:49 2013	(r254947)
@@ -2124,11 +2124,6 @@ retry_space:
 			else {
 				ssize_t resid;
 
-				/*
-				 * Ensure that our page is still around
-				 * when the I/O completes.
-				 */
-				vm_page_io_start(pg);
 				VM_OBJECT_UNLOCK(obj);
 
 				/*
@@ -2144,10 +2139,8 @@ retry_space:
 				    IO_VMIO | ((MAXBSIZE / bsize) << IO_SEQSHIFT),
 				    td->td_ucred, NOCRED, &resid, td);
 				VFS_UNLOCK_GIANT(vfslocked);
-				VM_OBJECT_LOCK(obj);
-				vm_page_io_finish(pg);
-				if (!error)
-					VM_OBJECT_UNLOCK(obj);
+				if (error)
+					VM_OBJECT_LOCK(obj);
 				mbstat.sf_iocnt++;
 			}
 			if (error) {


More information about the svn-src-stable-9 mailing list