summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-06-15 10:24:04 +0300
committerJens Axboe <axboe@kernel.dk>2020-06-15 08:51:34 -0600
commit44e728b8aae0bb6d4229129083974f9dea43f50b (patch)
tree0b34f50ac8706d4c8d9ee801bf680ea06a27e10c /fs/io_uring.c
parent4f26bda1522c35d2701fc219368c7101c17005c1 (diff)
downloadlwn-44e728b8aae0bb6d4229129083974f9dea43f50b.tar.gz
lwn-44e728b8aae0bb6d4229129083974f9dea43f50b.zip
io_uring: cancel all task's requests on exit
If a process is going away, io_uring_flush() will cancel only 1 request with a matching pid. Cancel all of them Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 94bd88556c1e..ad5128a40c14 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7424,6 +7424,13 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
}
}
+static bool io_cancel_pid_cb(struct io_wq_work *work, void *data)
+{
+ pid_t pid = (pid_t) (unsigned long) data;
+
+ return work->task_pid == pid;
+}
+
static int io_uring_flush(struct file *file, void *data)
{
struct io_ring_ctx *ctx = file->private_data;
@@ -7433,8 +7440,11 @@ static int io_uring_flush(struct file *file, void *data)
/*
* If the task is going away, cancel work it may have pending
*/
- if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
- io_wq_cancel_pid(ctx->io_wq, task_pid_vnr(current));
+ if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) {
+ void *data = (void *) (unsigned long)task_pid_vnr(current);
+
+ io_wq_cancel_cb(ctx->io_wq, io_cancel_pid_cb, data, true);
+ }
return 0;
}