io_uring: add support for IORING_OP_POLL
authorJens Axboe <axboe@kernel.dk>
Thu, 17 Jan 2019 16:41:58 +0000 (09:41 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 6 Mar 2019 20:00:12 +0000 (13:00 -0700)
commit221c5eb2338232f7340386de1c43decc32682e58
treefde88d2471110380c7254548dd88eb3c842b94f8
parentc16361c1d805b6ea50c3c1fc5c314e944c71a984
io_uring: add support for IORING_OP_POLL

This is basically a direct port of bfe4037e722e, which implements a
one-shot poll command through aio. Description below is based on that
commit as well. However, instead of adding a POLL command and relying
on io_cancel(2) to remove it, we mimic the epoll(2) interface of
having a command to add a poll notification, IORING_OP_POLL_ADD,
and one to remove it again, IORING_OP_POLL_REMOVE.

To poll for a file descriptor the application should submit an sqe of
type IORING_OP_POLL. It will poll the fd for the events specified in the
poll_events field.

Unlike poll or epoll without EPOLLONESHOT this interface always works in
one shot mode, that is once the sqe is completed, it will have to be
resubmitted.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Based-on-code-from: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c
include/uapi/linux/io_uring.h