Skip to content

Commit 80ad894

Browse files
isilenceaxboe
authored andcommitted
io-wq: remove io_wq_flush and IO_WQ_WORK_INTERNAL
io_wq_flush() is buggy, during cancelation of a flush, the associated work may be passed to the caller's (i.e. io_uring) @match callback. That callback is expecting it to be embedded in struct io_kiocb. Cancelation of internal work probably doesn't make a lot of sense to begin with. As the flush helper is no longer used, just delete it and the associated work flag. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent fc04c39 commit 80ad894

File tree

2 files changed

+1
-39
lines changed

2 files changed

+1
-39
lines changed

fs/io-wq.c

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static void io_worker_handle_work(struct io_worker *worker)
502502
if (worker->mm)
503503
work->flags |= IO_WQ_WORK_HAS_MM;
504504

505-
if (wq->get_work && !(work->flags & IO_WQ_WORK_INTERNAL)) {
505+
if (wq->get_work) {
506506
put_work = work;
507507
wq->get_work(work);
508508
}
@@ -1057,42 +1057,6 @@ enum io_wq_cancel io_wq_cancel_pid(struct io_wq *wq, pid_t pid)
10571057
return ret;
10581058
}
10591059

1060-
struct io_wq_flush_data {
1061-
struct io_wq_work work;
1062-
struct completion done;
1063-
};
1064-
1065-
static void io_wq_flush_func(struct io_wq_work **workptr)
1066-
{
1067-
struct io_wq_work *work = *workptr;
1068-
struct io_wq_flush_data *data;
1069-
1070-
data = container_of(work, struct io_wq_flush_data, work);
1071-
complete(&data->done);
1072-
}
1073-
1074-
/*
1075-
* Doesn't wait for previously queued work to finish. When this completes,
1076-
* it just means that previously queued work was started.
1077-
*/
1078-
void io_wq_flush(struct io_wq *wq)
1079-
{
1080-
struct io_wq_flush_data data;
1081-
int node;
1082-
1083-
for_each_node(node) {
1084-
struct io_wqe *wqe = wq->wqes[node];
1085-
1086-
if (!node_online(node))
1087-
continue;
1088-
init_completion(&data.done);
1089-
INIT_IO_WORK(&data.work, io_wq_flush_func);
1090-
data.work.flags |= IO_WQ_WORK_INTERNAL;
1091-
io_wqe_enqueue(wqe, &data.work);
1092-
wait_for_completion(&data.done);
1093-
}
1094-
}
1095-
10961060
struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
10971061
{
10981062
int ret = -ENOMEM, node;

fs/io-wq.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ enum {
88
IO_WQ_WORK_HAS_MM = 2,
99
IO_WQ_WORK_HASHED = 4,
1010
IO_WQ_WORK_UNBOUND = 32,
11-
IO_WQ_WORK_INTERNAL = 64,
1211
IO_WQ_WORK_CB = 128,
1312
IO_WQ_WORK_NO_CANCEL = 256,
1413
IO_WQ_WORK_CONCURRENT = 512,
@@ -100,7 +99,6 @@ void io_wq_destroy(struct io_wq *wq);
10099

101100
void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
102101
void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val);
103-
void io_wq_flush(struct io_wq *wq);
104102

105103
void io_wq_cancel_all(struct io_wq *wq);
106104
enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork);

0 commit comments

Comments
 (0)