summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-04-14 13:38:36 +0100
committerJens Axboe <axboe@kernel.dk>2021-04-14 10:43:47 -0600
commit9096af3e9c8734a34703bd9fb5ab14292296f911 (patch)
tree1b77b6d1a0a0fa9facdeb494c6e18dba97a969c0 /fs/io_uring.c
parent9ba5fac8cf3b607652397f863dc229bbc8c3cbc1 (diff)
io_uring: add helper for parsing poll events
Isolate poll mask SQE parsing and preparations into a new function, which will be reused shortly. Fixes: b69de288e913 ("io_uring: allow events and user_data update of running poll requests") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 28fc99bf9ede..9db4c99dfbf4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5282,6 +5282,20 @@ static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr,
return -EALREADY;
}
+static __poll_t io_poll_parse_events(const struct io_uring_sqe *sqe,
+ unsigned int flags)
+{
+ u32 events;
+
+ events = READ_ONCE(sqe->poll32_events);
+#ifdef __BIG_ENDIAN
+ events = swahw32(events);
+#endif
+ if (!(flags & IORING_POLL_ADD_MULTI))
+ events |= EPOLLONESHOT;
+ return demangle_poll(events) | (events & (EPOLLEXCLUSIVE|EPOLLONESHOT));
+}
+
static int io_poll_remove_prep(struct io_kiocb *req,
const struct io_uring_sqe *sqe)
{
@@ -5343,14 +5357,8 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
if (flags & ~(IORING_POLL_ADD_MULTI | IORING_POLL_UPDATE_EVENTS |
IORING_POLL_UPDATE_USER_DATA))
return -EINVAL;
- events = READ_ONCE(sqe->poll32_events);
-#ifdef __BIG_ENDIAN
- events = swahw32(events);
-#endif
- if (!(flags & IORING_POLL_ADD_MULTI))
- events |= EPOLLONESHOT;
- events = demangle_poll(events) |
- (events & (EPOLLEXCLUSIVE|EPOLLONESHOT));
+
+ events = io_poll_parse_events(sqe, flags);
if (flags & (IORING_POLL_UPDATE_EVENTS|IORING_POLL_UPDATE_USER_DATA)) {
struct io_poll_update *poll_upd = &req->poll_update;