public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-next 2/7] io_uring: hold locks for io_req_complete_failed
Date: Wed, 23 Nov 2022 11:33:37 +0000	[thread overview]
Message-ID: <70760344eadaecf2939287084b9d4ba5c05a6984.1669203009.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

A preparation patch, make sure we always hold uring_lock around
io_req_complete_failed(). The only place deviating from the rule
is io_cancel_defer_files(), queue a tw instead.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 2087ada65284..a4e6866f24c8 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -861,9 +861,12 @@ inline void __io_req_complete(struct io_kiocb *req, unsigned issue_flags)
 }
 
 void io_req_complete_failed(struct io_kiocb *req, s32 res)
+	__must_hold(&ctx->uring_lock)
 {
 	const struct io_op_def *def = &io_op_defs[req->opcode];
 
+	lockdep_assert_held(&req->ctx->uring_lock);
+
 	req_set_fail(req);
 	io_req_set_res(req, res, io_put_kbuf(req, IO_URING_F_UNLOCKED));
 	if (def->fail)
@@ -1614,6 +1617,7 @@ static u32 io_get_sequence(struct io_kiocb *req)
 }
 
 static __cold void io_drain_req(struct io_kiocb *req)
+	__must_hold(&ctx->uring_lock)
 {
 	struct io_ring_ctx *ctx = req->ctx;
 	struct io_defer_entry *de;
@@ -2847,7 +2851,7 @@ static __cold bool io_cancel_defer_files(struct io_ring_ctx *ctx,
 	while (!list_empty(&list)) {
 		de = list_first_entry(&list, struct io_defer_entry, list);
 		list_del_init(&de->list);
-		io_req_complete_failed(de->req, -ECANCELED);
+		io_req_task_queue_fail(de->req, -ECANCELED);
 		kfree(de);
 	}
 	return true;
-- 
2.38.1


  parent reply	other threads:[~2022-11-23 11:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 11:33 [PATCH for-next 0/7] iopoll cqe posting fixes Pavel Begunkov
2022-11-23 11:33 ` [PATCH for-next 1/7] io_uring: add completion locking for iopoll Pavel Begunkov
2022-11-23 11:33 ` Pavel Begunkov [this message]
2022-11-23 11:33 ` [PATCH for-next 3/7] io_uring: use io_req_task_complete() in timeout Pavel Begunkov
2022-11-23 11:33 ` [PATCH for-next 4/7] io_uring: remove io_req_tw_post_queue Pavel Begunkov
2022-11-23 11:33 ` [PATCH for-next 5/7] io_uring: inline __io_req_complete_put() Pavel Begunkov
2022-11-23 11:33 ` [PATCH for-next 6/7] io_uring: iopoll protect complete_post Pavel Begunkov
2022-11-23 11:33 ` [PATCH for-next 7/7] io_uring: remove iopoll spinlock Pavel Begunkov
2022-11-23 17:51 ` [PATCH for-next 0/7] iopoll cqe posting fixes Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70760344eadaecf2939287084b9d4ba5c05a6984.1669203009.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox