Commit 2941267b authored by Pavel Begunkov's avatar Pavel Begunkov Committed by 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: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 003e8dcc
...@@ -8785,14 +8785,17 @@ static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file) ...@@ -8785,14 +8785,17 @@ static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file)
/* /*
* Remove this io_uring_file -> task mapping. * 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 io_uring_task *tctx = current->io_uring;
struct file *file;
file = xa_erase(&tctx->xa, index);
if (!file)
return;
if (tctx->last == file) if (tctx->last == file)
tctx->last = NULL; tctx->last = NULL;
file = xa_erase(&tctx->xa, (unsigned long)file);
if (file)
fput(file); fput(file);
} }
...@@ -8802,7 +8805,7 @@ 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; unsigned long index;
xa_for_each(&tctx->xa, index, file) xa_for_each(&tctx->xa, index, file)
io_uring_del_task_file(file); io_uring_del_task_file(index);
if (tctx->io_wq) { if (tctx->io_wq) {
io_wq_put_and_exit(tctx->io_wq); io_wq_put_and_exit(tctx->io_wq);
tctx->io_wq = NULL; tctx->io_wq = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment