Commit 6b81928d authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: pass files into kill timeouts/poll

Make io_poll_remove_all() and io_kill_timeouts() to match against files
as well. A preparation patch, effectively not used by now.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b52fda00
...@@ -1589,14 +1589,15 @@ static bool io_task_match(struct io_kiocb *req, struct task_struct *tsk) ...@@ -1589,14 +1589,15 @@ static bool io_task_match(struct io_kiocb *req, struct task_struct *tsk)
/* /*
* Returns true if we found and killed one or more timeouts * Returns true if we found and killed one or more timeouts
*/ */
static bool io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk) static bool io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk,
struct files_struct *files)
{ {
struct io_kiocb *req, *tmp; struct io_kiocb *req, *tmp;
int canceled = 0; int canceled = 0;
spin_lock_irq(&ctx->completion_lock); spin_lock_irq(&ctx->completion_lock);
list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) { list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) {
if (io_task_match(req, tsk)) { if (io_match_task(req, tsk, files)) {
io_kill_timeout(req); io_kill_timeout(req);
canceled++; canceled++;
} }
...@@ -5473,7 +5474,8 @@ static bool io_poll_remove_one(struct io_kiocb *req) ...@@ -5473,7 +5474,8 @@ static bool io_poll_remove_one(struct io_kiocb *req)
/* /*
* Returns true if we found and killed one or more poll requests * Returns true if we found and killed one or more poll requests
*/ */
static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk) static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
struct files_struct *files)
{ {
struct hlist_node *tmp; struct hlist_node *tmp;
struct io_kiocb *req; struct io_kiocb *req;
...@@ -5485,7 +5487,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk) ...@@ -5485,7 +5487,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk)
list = &ctx->cancel_hash[i]; list = &ctx->cancel_hash[i];
hlist_for_each_entry_safe(req, tmp, list, hash_node) { hlist_for_each_entry_safe(req, tmp, list, hash_node) {
if (io_task_match(req, tsk)) if (io_match_task(req, tsk, files))
posted += io_poll_remove_one(req); posted += io_poll_remove_one(req);
} }
} }
...@@ -8626,8 +8628,8 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) ...@@ -8626,8 +8628,8 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
percpu_ref_kill(&ctx->refs); percpu_ref_kill(&ctx->refs);
mutex_unlock(&ctx->uring_lock); mutex_unlock(&ctx->uring_lock);
io_kill_timeouts(ctx, NULL); io_kill_timeouts(ctx, NULL, NULL);
io_poll_remove_all(ctx, NULL); io_poll_remove_all(ctx, NULL, NULL);
if (ctx->io_wq) if (ctx->io_wq)
io_wq_cancel_all(ctx->io_wq); io_wq_cancel_all(ctx->io_wq);
...@@ -8858,8 +8860,8 @@ static void __io_uring_cancel_task_requests(struct io_ring_ctx *ctx, ...@@ -8858,8 +8860,8 @@ static void __io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
} }
} }
ret |= io_poll_remove_all(ctx, task); ret |= io_poll_remove_all(ctx, task, NULL);
ret |= io_kill_timeouts(ctx, task); ret |= io_kill_timeouts(ctx, task, NULL);
if (!ret) if (!ret)
break; break;
io_run_task_work(); io_run_task_work();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment