diff mbox series

[5.10-stable,1/3] io_uring: synchronise IOPOLL on task_submit fail

Message ID b965dc7a6bfb1adbe5b4bcd9a363a38d662a3195.1610485688.git.asml.silence@gmail.com
State New
Headers show
Series backports for 5.10 | expand

Commit Message

Pavel Begunkov Jan. 12, 2021, 9:17 p.m. UTC
commit 81b6d05ccad4f3d8a9dfb091fb46ad6978ee40e4 upstream

io_req_task_submit() might be called for IOPOLL, do the fail path under
uring_lock to comply with IOPOLL synchronisation based solely on it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/io_uring.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Sasha Levin Jan. 13, 2021, 4:54 p.m. UTC | #1
On Tue, Jan 12, 2021 at 09:17:24PM +0000, Pavel Begunkov wrote:
>commit 81b6d05ccad4f3d8a9dfb091fb46ad6978ee40e4 upstream

>

>io_req_task_submit() might be called for IOPOLL, do the fail path under

>uring_lock to comply with IOPOLL synchronisation based solely on it.


Just curious, why did the stable tag disappear from this backport?

Otherwise, I've queued up the series, thanks!

-- 
Thanks,
Sasha
Pavel Begunkov Jan. 13, 2021, 4:58 p.m. UTC | #2
On 13/01/2021 16:54, Sasha Levin wrote:
> On Tue, Jan 12, 2021 at 09:17:24PM +0000, Pavel Begunkov wrote:

>> commit 81b6d05ccad4f3d8a9dfb091fb46ad6978ee40e4 upstream

>>

>> io_req_task_submit() might be called for IOPOLL, do the fail path under

>> uring_lock to comply with IOPOLL synchronisation based solely on it.

> 

> Just curious, why did the stable tag disappear from this backport?


Probably I just didn't pay attention and erased while adding "upstream
commit" and so. Didn't know that it's better to leave it though.

> Otherwise, I've queued up the series, thanks!


Thanks!

-- 
Pavel Begunkov
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 1f798c5c4213..3974b4f124b6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2047,14 +2047,15 @@  static void io_req_task_cancel(struct callback_head *cb)
 static void __io_req_task_submit(struct io_kiocb *req)
 {
 	struct io_ring_ctx *ctx = req->ctx;
+	bool fail;
 
-	if (!__io_sq_thread_acquire_mm(ctx)) {
-		mutex_lock(&ctx->uring_lock);
+	fail = __io_sq_thread_acquire_mm(ctx);
+	mutex_lock(&ctx->uring_lock);
+	if (!fail)
 		__io_queue_sqe(req, NULL);
-		mutex_unlock(&ctx->uring_lock);
-	} else {
+	else
 		__io_req_task_cancel(req, -EFAULT);
-	}
+	mutex_unlock(&ctx->uring_lock);
 }
 
 static void io_req_task_submit(struct callback_head *cb)