Skip to content

Commit 76e1b64

Browse files
committed
io_uring: return cancelation status from poll/timeout/files handlers
Return whether we found and canceled requests or not. This is in preparation for using this information, no functional changes in this patch. Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e3bc8e9 commit 76e1b64

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

fs/io_uring.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,16 +1229,23 @@ static bool io_task_match(struct io_kiocb *req, struct task_struct *tsk)
12291229
return false;
12301230
}
12311231

1232-
static void io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk)
1232+
/*
1233+
* Returns true if we found and killed one or more timeouts
1234+
*/
1235+
static bool io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk)
12331236
{
12341237
struct io_kiocb *req, *tmp;
1238+
int canceled = 0;
12351239

12361240
spin_lock_irq(&ctx->completion_lock);
12371241
list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) {
1238-
if (io_task_match(req, tsk))
1242+
if (io_task_match(req, tsk)) {
12391243
io_kill_timeout(req);
1244+
canceled++;
1245+
}
12401246
}
12411247
spin_unlock_irq(&ctx->completion_lock);
1248+
return canceled != 0;
12421249
}
12431250

12441251
static void __io_queue_deferred(struct io_ring_ctx *ctx)
@@ -5013,7 +5020,10 @@ static bool io_poll_remove_one(struct io_kiocb *req)
50135020
return do_complete;
50145021
}
50155022

5016-
static void io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk)
5023+
/*
5024+
* Returns true if we found and killed one or more poll requests
5025+
*/
5026+
static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk)
50175027
{
50185028
struct hlist_node *tmp;
50195029
struct io_kiocb *req;
@@ -5033,6 +5043,8 @@ static void io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk)
50335043

50345044
if (posted)
50355045
io_cqring_ev_posted(ctx);
5046+
5047+
return posted != 0;
50365048
}
50375049

50385050
static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
@@ -8178,11 +8190,14 @@ static void io_cancel_defer_files(struct io_ring_ctx *ctx,
81788190
}
81798191
}
81808192

8181-
static void io_uring_cancel_files(struct io_ring_ctx *ctx,
8193+
/*
8194+
* Returns true if we found and killed one or more files pinning requests
8195+
*/
8196+
static bool io_uring_cancel_files(struct io_ring_ctx *ctx,
81828197
struct files_struct *files)
81838198
{
81848199
if (list_empty_careful(&ctx->inflight_list))
8185-
return;
8200+
return false;
81868201

81878202
io_cancel_defer_files(ctx, files);
81888203
/* cancel all at once, should be faster than doing it one by one*/
@@ -8218,6 +8233,8 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
82188233
schedule();
82198234
finish_wait(&ctx->inflight_wait, &wait);
82208235
}
8236+
8237+
return true;
82218238
}
82228239

82238240
static bool io_cancel_task_cb(struct io_wq_work *work, void *data)

0 commit comments

Comments
 (0)