Skip to contentSkip to conversation

tw handlers cleanups

PATCH Applied Pavel Begunkov 2 participants 4 messages Aug 19, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tw handlers cleanups

Two simple patches cleaning task_work handlers.

Pavel Begunkov (2):
io_uring: remove mutex in io_req_task_cancel()
io_uring: dedup tw-based request failing

 fs/io_uring.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 io_uring: remove mutex in io_req_task_cancel()

io_req_complete_failed() only does io_req_complete_post(), which we don't need to protect by ->uring_lock, so remove mutex_lock / unlock from there.

---
 fs/io_uring.c | 5 -----
 1 file changed, 5 deletions(-)
fs/io_uring.c +0 -5
index 5e99473ad6fc..bdab831a1185 100644
@@ -2111,12 +2111,7 @@ static void io_req_task_work_add(struct io_kiocb *req)
 
 static void io_req_task_cancel(struct io_kiocb *req)
 {
-	struct io_ring_ctx *ctx = req->ctx;
-
-	/* ctx is guaranteed to stay alive while we hold uring_lock */
-	mutex_lock(&ctx->uring_lock);
 	io_req_complete_failed(req, req->result);
-	mutex_unlock(&ctx->uring_lock);
 }
 
 static void io_req_task_submit(struct io_kiocb *req)
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 io_uring: dedup tw-based request failing

In reply to Pavel Begunkov

io_req_task_timeout() closely follows io_req_task_cancel(), so remove it and replace with io_req_task_queue_fail().

---
 fs/io_uring.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
fs/io_uring.c +1 -8
index bdab831a1185..581c994a4e4f 100644
@@ -5529,12 +5529,6 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)
 	return 0;
 }
 
-static void io_req_task_timeout(struct io_kiocb *req)
-{
-	req_set_fail(req);
-	io_req_complete_post(req, -ETIME, 0);
-}
-
 static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
 {
 	struct io_timeout_data *data = container_of(timer,
@@ -5549,8 +5543,7 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
 		atomic_read(&req->ctx->cq_timeouts) + 1);
 	spin_unlock_irqrestore(&ctx->timeout_lock, flags);
 
-	req->io_task_work.func = io_req_task_timeout;
-	io_req_task_work_add(req);
+	io_req_task_queue_fail(req, -ETIME);
 	return HRTIMER_NORESTART;
 }
 
Signature · 1 line
2.32.0
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 8 lines · Pavel Begunkov

Two simple patches cleaning task_work handlers.

Pavel Begunkov (2):
io_uring: remove mutex in io_req_task_cancel()
io_uring: dedup tw-based request failing

 fs/io_uring.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe