提交 34474b3c 编写于 作者: H Hillf Danton 提交者: Xiaoguang Wang

io-uring: drop 'free_pfile' in struct io_file_put

to #28170604

commit a5318d3cdffbecf075928363d7e4becfeddabfcb upstream

Sync removal of file is only used in case of a GFP_KERNEL kmalloc
failure at the cost of io_file_put::done and work flush, while a
glich like it can be handled at the call site without too much pain.

That said, what is proposed is to drop sync removing of file, and
the kink in neck as well.
Signed-off-by: NHillf Danton <hdanton@sina.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 8658724a
......@@ -6380,7 +6380,6 @@ static void io_ring_file_put(struct io_ring_ctx *ctx, struct file *file)
struct io_file_put {
struct llist_node llist;
struct file *file;
bool free_pfile;
};
static void io_ring_file_ref_flush(struct fixed_file_data *data)
......@@ -6391,8 +6390,7 @@ static void io_ring_file_ref_flush(struct fixed_file_data *data)
while ((node = llist_del_all(&data->put_llist)) != NULL) {
llist_for_each_entry_safe(pfile, tmp, node, llist) {
io_ring_file_put(data->ctx, pfile->file);
if (pfile->free_pfile)
kfree(pfile);
kfree(pfile);
}
}
}
......@@ -6587,32 +6585,18 @@ static void io_atomic_switch(struct percpu_ref *ref)
percpu_ref_get(&data->refs);
}
static bool io_queue_file_removal(struct fixed_file_data *data,
static int io_queue_file_removal(struct fixed_file_data *data,
struct file *file)
{
struct io_file_put *pfile, pfile_stack;
struct io_file_put *pfile;
/*
* If we fail allocating the struct we need for doing async reomval
* of this file, just punt to sync and wait for it.
*/
pfile = kzalloc(sizeof(*pfile), GFP_KERNEL);
if (!pfile) {
pfile = &pfile_stack;
pfile->free_pfile = false;
} else
pfile->free_pfile = true;
if (!pfile)
return -ENOMEM;
pfile->file = file;
llist_add(&pfile->llist, &data->put_llist);
if (pfile == &pfile_stack) {
percpu_ref_switch_to_atomic(&data->refs, io_atomic_switch);
flush_work(&data->ref_work);
return false;
}
return true;
return 0;
}
static int __io_sqe_files_update(struct io_ring_ctx *ctx,
......@@ -6647,9 +6631,11 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
index = i & IORING_FILE_TABLE_MASK;
if (table->files[index]) {
file = io_file_from_index(ctx, index);
err = io_queue_file_removal(data, file);
if (err)
break;
table->files[index] = NULL;
if (io_queue_file_removal(data, file))
ref_switch = true;
ref_switch = true;
}
if (fd != -1) {
file = fget(fd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册