diff mbox series

[5.19,1/3] io_uring: fail links when poll fails

Message ID a78aad962460f9fdfe4aa4c0b62425c88f9415bc.1655852245.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series poll fixes | expand

Commit Message

Pavel Begunkov June 21, 2022, 11 p.m. UTC
Don't forget to cancel all linked requests of poll request when
__io_arm_poll_handler() failed.

Fixes: aa43477b04025 ("io_uring: poll rework")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jens Axboe June 22, 2022, 3:34 a.m. UTC | #1
On 6/21/22 5:00 PM, Pavel Begunkov wrote:
> Don't forget to cancel all linked requests of poll request when
> __io_arm_poll_handler() failed.
> 
> Fixes: aa43477b04025 ("io_uring: poll rework")
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>  fs/io_uring.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index dffa85d4dc7a..d5ea3c6167b5 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -7405,6 +7405,8 @@ static int io_poll_add(struct io_kiocb *req, unsigned int issue_flags)
>  	ipt.pt._qproc = io_poll_queue_proc;
>  
>  	ret = __io_arm_poll_handler(req, &req->poll, &ipt, poll->events);
> +	if (!ret && ipt.error)
> +		req_set_fail(req);
>  	ret = ret ?: ipt.error;
>  	if (ret)
>  		__io_req_complete(req, issue_flags, ret, 0);

We could make this:

	if (!ret && ipt.error) {
		req_set_fail(req);
		ret = ipt.error;
	}

and kill that ternary, but we could also then go a bit further with the
completion. So let's just leave that for 5.20.
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index dffa85d4dc7a..d5ea3c6167b5 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7405,6 +7405,8 @@  static int io_poll_add(struct io_kiocb *req, unsigned int issue_flags)
 	ipt.pt._qproc = io_poll_queue_proc;
 
 	ret = __io_arm_poll_handler(req, &req->poll, &ipt, poll->events);
+	if (!ret && ipt.error)
+		req_set_fail(req);
 	ret = ret ?: ipt.error;
 	if (ret)
 		__io_req_complete(req, issue_flags, ret, 0);