All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring: fix assign file locking issues
@ 2022-04-12 14:24 Pavel Begunkov
  2022-04-12 14:39 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2022-04-12 14:24 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

io-wq work cancellation path can't take uring_lock as how it's done on
file assignment, we have to handle IO_WQ_WORK_CANCEL first, this fixes
encountered hangs.

Fixes: 6bf9c47a3989 ("io_uring: defer file assignment")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index f2269ffe09eb..cbd876c023b1 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7318,16 +7318,18 @@ static void io_wq_submit_work(struct io_wq_work *work)
 	if (timeout)
 		io_queue_linked_timeout(timeout);
 
-	if (!io_assign_file(req, issue_flags)) {
-		err = -EBADF;
-		work->flags |= IO_WQ_WORK_CANCEL;
-	}
 
 	/* either cancelled or io-wq is dying, so don't touch tctx->iowq */
 	if (work->flags & IO_WQ_WORK_CANCEL) {
+fail:
 		io_req_task_queue_fail(req, err);
 		return;
 	}
+	if (!io_assign_file(req, issue_flags)) {
+		err = -EBADF;
+		work->flags |= IO_WQ_WORK_CANCEL;
+		goto fail;
+	}
 
 	if (req->flags & REQ_F_FORCE_ASYNC) {
 		bool opcode_poll = def->pollin || def->pollout;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] io_uring: fix assign file locking issues
  2022-04-12 14:24 [PATCH 1/1] io_uring: fix assign file locking issues Pavel Begunkov
@ 2022-04-12 14:39 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-04-12 14:39 UTC (permalink / raw)
  To: asml.silence, io-uring

On Tue, 12 Apr 2022 15:24:43 +0100, Pavel Begunkov wrote:
> io-wq work cancellation path can't take uring_lock as how it's done on
> file assignment, we have to handle IO_WQ_WORK_CANCEL first, this fixes
> encountered hangs.
> 
> 

Applied, thanks!

[1/1] io_uring: fix assign file locking issues
      commit: 0f8da75b51ac863b9435368bd50691718cc454b0

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-12 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 14:24 [PATCH 1/1] io_uring: fix assign file locking issues Pavel Begunkov
2022-04-12 14:39 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.