summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-06-15eventfd: only return events requested in poll_mask()Avi Kivity1-2/+2
The ->poll_mask() operation has a mask of events that the caller is interested in, but we're returning all events regardless. Change to return only the events the caller is interested in. This fixes aio IO_CMD_POLL returning immediately when called with POLLIN on an eventfd, since an eventfd is almost always ready for a write. Signed-off-by: Avi Kivity <avi@scylladb.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-06-15aio: mark __aio_sigset::sigmask constAvi Kivity1-1/+1
io_pgetevents() will not change the signal mask. Mark it const to make it clear and to reduce the need for casts in user code. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Avi Kivity <avi@scylladb.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-06-04fs: aio ioprio use ioprio_check_cap ret valAdam Manzanares1-2/+2
Previously the value was ignored. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-06-04fs: aio ioprio add explicit block layer dependenceAdam Manzanares1-0/+7
Previously, the ioprio_check_cap function was only defined when CONFIG_BLOCK was set. Make this relationship explicit and add a stub for !CONFIG_BLOCK. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-31fs: iomap dio set bio prio from kiocb prioAdam Manzanares1-0/+1
Now that kiocb has an ioprio field copy this over to the bio when it is created from the kiocb during direct IO. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-31fs: blkdev set bio prio from kiocb prioAdam Manzanares1-0/+2
Now that kiocb has an ioprio field copy this over to the bio when it is created from the kiocb. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-31fs: Add aio iopriority supportAdam Manzanares4-0/+23
This is the per-I/O equivalent of the ioprio_set system call. When IOCB_FLAG_IOPRIO is set on the iocb aio_flags field, then we set the newly added kiocb ki_ioprio field to the value in the iocb aio_reqprio field. This patch depends on block: add ioprio_check_cap function. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-31fs: Convert kiocb rw_hint from enum to u16Adam Manzanares2-3/+12
In order to avoid kiocb bloat for per command iopriority support, rw_hint is converted from enum to a u16. Added a guard around ki_hint assignment. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-31block: add ioprio_check_cap functionAdam Manzanares2-6/+18
Aio per command iopriority support introduces a second interface between userland and the kernel capable of passing iopriority. The aio interface also needs the ability to verify that the submitting context has sufficient privileges to submit IOPRIO_RT commands. This patch creates the ioprio_check_cap function to be used by the ioprio_set system call and also by the aio interface. Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-30aio: sanitize the limit checking in io_submit(2)Al Viro1-8/+6
as it is, the logics in native io_submit(2) is "if asked for more than LONG_MAX/sizeof(pointer) iocbs to submit, don't bother with more than LONG_MAX/sizeof(pointer)" (i.e. 512M requests on 32bit and 1E requests on 64bit) while compat io_submit(2) goes with "stop after the first PAGE_SIZE/sizeof(pointer) iocbs", i.e. 1K or so. Which is * inconsistent * *way* too much in native case * possibly too little in compat one and * wrong anyway, since the natural point where we ought to stop bothering is ctx->nr_events Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-30aio: fold do_io_submit() into callersAl Viro1-54/+45
get rid of insane "copy array of 32bit pointers into an array of native ones" glue. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-30aio: shift copyin of iocb into io_submit_one()Al Viro1-24/+22
Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-30aio_read_events_ring(): make a bit more readableAl Viro1-4/+3
The logics for 'avail' is * not past the tail of cyclic buffer * no more than asked * not past the end of buffer * not past the end of a page Unobfuscate the last part. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-30aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the ↵Al Viro1-14/+12
same way ... so just make them return 0 when caller does not need to destroy iocb Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-30aio: take list removal to (some) callers of aio_complete()Al Viro1-17/+21
We really want iocb out of io_cancel(2) reach before we start tearing it down. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-28aio: add missing break for the IOCB_CMD_FDSYNC caseChristoph Hellwig1-0/+1
Looks like this got lost in a merge. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-05-26random: convert to ->poll_maskChristoph Hellwig1-13/+16
The big change is that random_read_wait and random_write_wait are merged into a single waitqueue that uses keyed wakeups. Because wait_event_* doesn't know about that this will lead to occassional spurious wakeups in _random_read and add_hwgenerator_randomness, but wait_event_* is designed to handle these and were are not in a a hot path there. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-26timerfd: convert to ->poll_maskChristoph Hellwig1-11/+11
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26eventfd: switch to ->poll_maskChristoph Hellwig1-4/+11
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26pipe: convert to ->poll_maskChristoph Hellwig1-9/+13
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26crypto: af_alg: convert to ->poll_maskChristoph Hellwig4-16/+8
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/rxrpc: convert to ->poll_maskChristoph Hellwig1-7/+3
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/iucv: convert to ->poll_maskChristoph Hellwig2-7/+2
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/phonet: convert to ->poll_maskChristoph Hellwig1-5/+2
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/nfc: convert to ->poll_maskChristoph Hellwig1-6/+3
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/caif: convert to ->poll_maskChristoph Hellwig1-8/+4
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/bluetooth: convert to ->poll_maskChristoph Hellwig5-9/+6
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/sctp: convert to ->poll_maskChristoph Hellwig4-7/+4
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/tipc: convert to ->poll_maskChristoph Hellwig1-9/+5
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/vmw_vsock: convert to ->poll_maskChristoph Hellwig1-13/+6
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/atm: convert to ->poll_maskChristoph Hellwig4-11/+6
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/dccp: convert to ->poll_maskChristoph Hellwig4-15/+5
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net: convert datagram_poll users tp ->poll_maskChristoph Hellwig31-59/+52
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-26net/unix: convert to ->poll_maskChristoph Hellwig1-19/+11
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net/tcp: convert to ->poll_maskChristoph Hellwig4-21/+9
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net: remove sock_no_pollChristoph Hellwig10-17/+0
Now that sock_poll handles a NULL ->poll or ->poll_mask there is no need for a stub. Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net: add support for ->poll_mask in proto_opsChristoph Hellwig2-5/+44
The socket file operations still implement ->poll until all protocols are switched over. Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26net: refactor socket_pollChristoph Hellwig2-17/+19
Factor out two busy poll related helpers for late reuse, and remove a command that isn't very helpful, especially with the __poll_t annotations in place. Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26aio: try to complete poll iocbs without context switchChristoph Hellwig1-3/+17
If we can acquire ctx_lock without spinning we can just remove our iocb from the active_reqs list, and thus complete the iocbs from the wakeup context. Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26aio: implement IOCB_CMD_POLLChristoph Hellwig2-5/+135
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT this interface always works in one shot mode, that is once the iocb is completed, it will have to be resubmitted. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-26aio: simplify cancellationChristoph Hellwig1-42/+6
With the current aio code there is no need for the magic KIOCB_CANCELLED value, as a cancelation just kicks the driver to queue the completion ASAP, with all actual completion handling done in another thread. Given that both the completion path and cancelation take the context lock there is no need for magic cmpxchg loops either. If we remove iocbs from the active list after calling ->ki_cancel (but with ctx_lock still held), we can also rely on the invariant thay anything found on the list has a ->ki_cancel callback and can be cancelled, further simplifing the code. Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26aio: simplify KIOCB_KEY handlingChristoph Hellwig2-9/+7
No need to pass the key field to lookup_iocb to compare it with KIOCB_KEY, as we can do that right after retrieving it from userspace. Also move the KIOCB_KEY definition to aio.c as it is an internal value not used by any other place in the kernel. Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26fs: introduce new ->get_poll_head and ->poll_mask methodsChristoph Hellwig5-7/+50
->get_poll_head returns the waitqueue that the poll operation is going to sleep on. Note that this means we can only use a single waitqueue for the poll, unlike some current drivers that use two waitqueues for different events. But now that we have keyed wakeups and heavily use those for poll there aren't that many good reason left to keep the multiple waitqueues, and if there are any ->poll is still around, the driver just won't support aio poll. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-26fs: add new vfs_poll and file_can_poll helpersChristoph Hellwig9-38/+32
These abstract out calls to the poll method in preparation for changes in how we poll. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-26fs: update documentation to mention __poll_t and match the codeChristoph Hellwig2-2/+2
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-26fs: cleanup do_pollfdChristoph Hellwig1-25/+23
Use straightline code with failure handling gotos instead of a lot of nested conditionals. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-26fs: unexport poll_schedule_timeoutChristoph Hellwig2-4/+1
No users outside of select.c. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-26uapi: turn __poll_t sparse checks on by defaultChristoph Hellwig1-4/+0
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-26Merge branch 'fixes' of ↵Christoph Hellwig26-120/+153
https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into aio-base
2018-05-24fix io_destroy()/aio_complete() raceAl Viro1-2/+1
If io_destroy() gets to cancelling everything that can be cancelled and gets to kiocb_cancel() calling the function driver has left in ->ki_cancel, it becomes vulnerable to a race with IO completion. At that point req is already taken off the list and aio_complete() does *NOT* spin until we (in free_ioctx_users()) releases ->ctx_lock. As the result, it proceeds to kiocb_free(), freing req just it gets passed to ->ki_cancel(). Fix is simple - remove from the list after the call of kiocb_cancel(). All instances of ->ki_cancel() already have to cope with the being called with iocb still on list - that's what happens in io_cancel(2). Cc: stable@kernel.org Fixes: 0460fef2a921 "aio: use cancellation list lazily" Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>