Re: [PATCH 2/3] io_uring: fail io-wq submission from a task_work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18/02/2021 22:32, Pavel Begunkov wrote:
> In case of failure io_wq_submit_work() needs to post an CQE and so
> potentially take uring_lock. The safest way to deal with it is to do
> that from under task_work where we can safely take the lock.
> 
> Also, as io_iopoll_check() holds the lock tight and releases it
> reluctantly, it will play nicer in the furuter with notifying an
> iopolling task about new such pending failed requests.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
> ---
> @@ -2371,11 +2371,22 @@ static void io_req_task_queue(struct io_kiocb *req)
>  	req->task_work.func = io_req_task_submit;
>  	ret = io_req_task_work_add(req);
>  	if (unlikely(ret)) {
> +		ret = -ECANCELED;

That's a stupid mistake. Jens, any chance you can fold in a diff below?

>  		percpu_ref_get(&req->ctx->refs);
>  		io_req_task_work_add_fallback(req, io_req_task_cancel);
>  	}
>  }

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 1cb5e40d9822..582306b1dfd1 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2371,7 +2371,7 @@ static void io_req_task_queue(struct io_kiocb *req)
 	req->task_work.func = io_req_task_submit;
 	ret = io_req_task_work_add(req);
 	if (unlikely(ret)) {
-		ret = -ECANCELED;
+		req->result = -ECANCELED;
 		percpu_ref_get(&req->ctx->refs);
 		io_req_task_work_add_fallback(req, io_req_task_cancel);
 	}



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux