diff options
author | John Baldwin <jhb@FreeBSD.org> | 2018-01-10 00:18:47 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2018-01-10 00:18:47 +0000 |
commit | f54c5606b3d06c7125cea71c4a12dfd934cbbc2d (patch) | |
tree | 3fe18bd1f66620f2f34edc963890112c3499d7a2 /sys/kern/vfs_aio.c | |
parent | f05c4956605faafcfbdc5d2b0a39d5c84d33d748 (diff) | |
download | src-f54c5606b3d06c7125cea71c4a12dfd934cbbc2d.tar.gz src-f54c5606b3d06c7125cea71c4a12dfd934cbbc2d.zip |
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
Notes
Notes:
svn path=/head/; revision=327755
Diffstat (limited to 'sys/kern/vfs_aio.c')
-rw-r--r-- | sys/kern/vfs_aio.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 569cf96985ba..06d136a76390 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -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); } |