Skip to content

Commit c7cafd5

Browse files
isilenceaxboe
authored andcommitted
io_uring/poll: fix POLLERR handling
8c8492c ("io_uring/net: don't retry connect operation on EPOLLERR") is a little dirty hack that 1) wrongfully assumes that POLLERR equals to a failed request, which breaks all POLLERR users, e.g. all error queue recv interfaces. 2) deviates the connection request behaviour from connect(2), and 3) racy and solved at a wrong level. Nothing can be done with 2) now, and 3) is beyond the scope of the patch. At least solve 1) by moving the hack out of generic poll handling into io_connect(). Cc: [email protected] Fixes: 8c8492c ("io_uring/net: don't retry connect operation on EPOLLERR") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/3dc89036388d602ebd84c28e5042e457bdfc952b.1752682444.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 08ca140 commit c7cafd5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

io_uring/net.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,9 +1738,11 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
17381738
int ret;
17391739
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
17401740

1741-
if (unlikely(req->flags & REQ_F_FAIL)) {
1742-
ret = -ECONNRESET;
1743-
goto out;
1741+
if (connect->in_progress) {
1742+
struct poll_table_struct pt = { ._key = EPOLLERR };
1743+
1744+
if (vfs_poll(req->file, &pt) & EPOLLERR)
1745+
goto get_sock_err;
17441746
}
17451747

17461748
file_flags = force_nonblock ? O_NONBLOCK : 0;
@@ -1765,8 +1767,10 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
17651767
* which means the previous result is good. For both of these,
17661768
* grab the sock_error() and use that for the completion.
17671769
*/
1768-
if (ret == -EBADFD || ret == -EISCONN)
1770+
if (ret == -EBADFD || ret == -EISCONN) {
1771+
get_sock_err:
17691772
ret = sock_error(sock_from_file(req->file)->sk);
1773+
}
17701774
}
17711775
if (ret == -ERESTARTSYS)
17721776
ret = -EINTR;

io_uring/poll.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
273273
return IOU_POLL_REISSUE;
274274
}
275275
}
276-
if (unlikely(req->cqe.res & EPOLLERR))
277-
req_set_fail(req);
278276
if (req->apoll_events & EPOLLONESHOT)
279277
return IOU_POLL_DONE;
280278

0 commit comments

Comments
 (0)