Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jan 2018 00:18:48 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r327755 - head/sys/kern
Message-ID:  <201801100018.w0A0ImEb083683@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Jan 10 00:18:47 2018
New Revision: 327755
URL: https://svnweb.freebsd.org/changeset/base/327755

Log:
  Allow the fast-path for disk AIO requests to fail requests.
  
  - If aio_qphysio() returns a non-zero error code, fail the request rather
    than queueing it to the AIO kproc pool to be retried via the slow path.
    Currently this means that if vm_fault_quick_hold_pages() reports an
    error, EFAULT is returned from the fast-path rather than retrying the
    request in the slow path where it will still fail with EFAULT.
  - If aio_qphysio() wishes to use the fast path for a device that doesn't
    support unmapped I/O but there are already the maximum number of
    such requests in flight, fail with EAGAIN as we do for other AIO
    resource limits rather than queueing the request to the AIO kproc pool.
  - Move the opcode check for aio_qphysio() out of the caller and into
    aio_qphysio() to simplify some logic and remove two goto's while here.
    It also uses a whitelist (only supported for LIO_READ / LIO_WRITE)
    rather than a blacklist (skipped for LIO_SYNC).
  
  PR:		217261
  Submitted by:	jkim (an earlier version)
  MFC after:	2 weeks
  Sponsored by:	Chelsio Communications

Modified:
  head/sys/kern/vfs_aio.c

Modified: head/sys/kern/vfs_aio.c
==============================================================================
--- head/sys/kern/vfs_aio.c	Wed Jan 10 00:08:57 2018	(r327754)
+++ head/sys/kern/vfs_aio.c	Wed Jan 10 00:18:47 2018	(r327755)
@@ -1228,6 +1228,9 @@ aio_qphysio(struct proc *p, struct kaiocb *job)
 	cb = &job->uaiocb;
 	fp = job->fd_file;
 
+	if (!(cb->aio_lio_opcode == LIO_WRITE ||
+	    cb->aio_lio_opcode == LIO_READ))
+		return (-1);
 	if (fp == NULL || fp->f_type != DTYPE_VNODE)
 		return (-1);
 
@@ -1268,7 +1271,7 @@ aio_qphysio(struct proc *p, struct kaiocb *job)
 			goto unref;
 		}
 		if (ki->kaio_buffer_count >= ki->kaio_ballowed_count) {
-			error = -1;
+			error = EAGAIN;
 			goto unref;
 		}
 
@@ -1700,27 +1703,13 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
 	struct kaiocb *job2;
 	struct vnode *vp;
 	struct mount *mp;
-	int error, opcode;
+	int error;
 	bool safe;
 
 	ki = job->userproc->p_aioinfo;
-	opcode = job->uaiocb.aio_lio_opcode;
-	if (opcode == LIO_SYNC)
-		goto queueit;
-
-	if ((error = aio_qphysio(job->userproc, job)) == 0)
-		goto done;
-#if 0
-	/*
-	 * XXX: This means qphysio() failed with EFAULT.  The current
-	 * behavior is to retry the operation via fo_read/fo_write.
-	 * Wouldn't it be better to just complete the request with an
-	 * error here?
-	 */
-	if (error > 0)
-		goto done;
-#endif
-queueit:
+	error = aio_qphysio(job->userproc, job);
+	if (error >= 0)
+		return (error);
 	safe = false;
 	if (fp->f_type == DTYPE_VNODE) {
 		vp = fp->f_vnode;
@@ -1770,7 +1759,6 @@ queueit:
 	default:
 		error = EINVAL;
 	}
-done:
 	return (error);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801100018.w0A0ImEb083683>