提交 2941267b 编写于 作者: P Pavel Begunkov 提交者: Jens Axboe

io_uring: make del_task_file more forgiving

Rework io_uring_del_task_file(), so it accepts an index to delete, and
it's not necessarily have to be in the ->xa. Infer file from xa_erase()
to maintain a single origin of truth.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 003e8dcc
......@@ -8785,15 +8785,18 @@ static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file)
/*
* Remove this io_uring_file -> task mapping.
*/
static void io_uring_del_task_file(struct file *file)
static void io_uring_del_task_file(unsigned long index)
{
struct io_uring_task *tctx = current->io_uring;
struct file *file;
file = xa_erase(&tctx->xa, index);
if (!file)
return;
if (tctx->last == file)
tctx->last = NULL;
file = xa_erase(&tctx->xa, (unsigned long)file);
if (file)
fput(file);
fput(file);
}
static void io_uring_clean_tctx(struct io_uring_task *tctx)
......@@ -8802,7 +8805,7 @@ static void io_uring_clean_tctx(struct io_uring_task *tctx)
unsigned long index;
xa_for_each(&tctx->xa, index, file)
io_uring_del_task_file(file);
io_uring_del_task_file(index);
if (tctx->io_wq) {
io_wq_put_and_exit(tctx->io_wq);
tctx->io_wq = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册