svn commit: r289941 - head/sys/kern

Pawel Jakub Dawidek pjd at FreeBSD.org
Sun Oct 25 18:48:10 UTC 2015


Author: pjd
Date: Sun Oct 25 18:48:09 2015
New Revision: 289941
URL: https://svnweb.freebsd.org/changeset/base/289941

Log:
  The aio_waitcomplete(2) syscall should not sleep when the given timeout
  is 0. Without this change it was sleeping for one tick. Maybe not a big
  deal, but it makes share/dtrace/blocking script to report that.
  
  Reviewed by:	jhb
  Differential Revision:	https://reviews.freebsd.org/D3814
  Sponsored by:	Wheel Systems, http://wheelsystems.com

Modified:
  head/sys/kern/vfs_aio.c

Modified: head/sys/kern/vfs_aio.c
==============================================================================
--- head/sys/kern/vfs_aio.c	Sun Oct 25 18:09:03 2015	(r289940)
+++ head/sys/kern/vfs_aio.c	Sun Oct 25 18:48:09 2015	(r289941)
@@ -2494,8 +2494,11 @@ kern_aio_waitcomplete(struct thread *td,
 
 	ops->store_aiocb(aiocbp, NULL);
 
-	timo = 0;
-	if (ts) {
+	if (ts == NULL) {
+		timo = 0;
+	} else if (ts->tv_sec == 0 && ts->tv_nsec == 0) {
+		timo = -1;
+	} else {
 		if ((ts->tv_nsec < 0) || (ts->tv_nsec >= 1000000000))
 			return (EINVAL);
 
@@ -2513,6 +2516,10 @@ kern_aio_waitcomplete(struct thread *td,
 	cb = NULL;
 	AIO_LOCK(ki);
 	while ((cb = TAILQ_FIRST(&ki->kaio_done)) == NULL) {
+		if (timo == -1) {
+			error = EWOULDBLOCK;
+			break;
+		}
 		ki->kaio_flags |= KAIO_WAKEUP;
 		error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
 		    "aiowc", timo);


More information about the svn-src-all mailing list