Skip to content

Commit 63fea89

Browse files
isilenceaxboe
authored andcommitted
io_uring/rsrc: infer node from ctx on io_queue_rsrc_removal
For io_queue_rsrc_removal() we should always use the current active rsrc node, don't pass it directly but let the function grab it from the context. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/d15939b4afea730978b4925685c2577538b823bb.1681822823.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2e6f45a commit 63fea89

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

io_uring/filetable.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
8585
return ret;
8686

8787
old_file = (struct file *)(file_slot->file_ptr & FFS_MASK);
88-
ret = io_queue_rsrc_removal(ctx->file_data, slot_index,
89-
ctx->rsrc_node, old_file);
88+
ret = io_queue_rsrc_removal(ctx->file_data, slot_index, old_file);
9089
if (ret)
9190
return ret;
9291

@@ -163,7 +162,7 @@ int io_fixed_fd_remove(struct io_ring_ctx *ctx, unsigned int offset)
163162
return -EBADF;
164163

165164
file = (struct file *)(file_slot->file_ptr & FFS_MASK);
166-
ret = io_queue_rsrc_removal(ctx->file_data, offset, ctx->rsrc_node, file);
165+
ret = io_queue_rsrc_removal(ctx->file_data, offset, file);
167166
if (ret)
168167
return ret;
169168

io_uring/rsrc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
409409

410410
if (file_slot->file_ptr) {
411411
file = (struct file *)(file_slot->file_ptr & FFS_MASK);
412-
err = io_queue_rsrc_removal(data, i, ctx->rsrc_node, file);
412+
err = io_queue_rsrc_removal(data, i, file);
413413
if (err)
414414
break;
415415
file_slot->file_ptr = 0;
@@ -492,7 +492,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
492492
i = array_index_nospec(up->offset + done, ctx->nr_user_bufs);
493493
if (ctx->user_bufs[i] != ctx->dummy_ubuf) {
494494
err = io_queue_rsrc_removal(ctx->buf_data, i,
495-
ctx->rsrc_node, ctx->user_bufs[i]);
495+
ctx->user_bufs[i]);
496496
if (unlikely(err)) {
497497
io_buffer_unmap(ctx, &imu);
498498
break;
@@ -680,9 +680,10 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
680680
return IOU_OK;
681681
}
682682

683-
int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
684-
struct io_rsrc_node *node, void *rsrc)
683+
int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx, void *rsrc)
685684
{
685+
struct io_ring_ctx *ctx = data->ctx;
686+
struct io_rsrc_node *node = ctx->rsrc_node;
686687
u64 *tag_slot = io_get_tag_slot(data, idx);
687688
struct io_rsrc_put *prsrc;
688689

io_uring/rsrc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ void io_rsrc_put_work(struct work_struct *work);
7070
void io_rsrc_node_destroy(struct io_ring_ctx *ctx, struct io_rsrc_node *ref_node);
7171
int __io_rsrc_node_switch_start(struct io_ring_ctx *ctx);
7272
struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx);
73-
int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
74-
struct io_rsrc_node *node, void *rsrc);
73+
int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx, void *rsrc);
7574
void io_rsrc_node_switch(struct io_ring_ctx *ctx,
7675
struct io_rsrc_data *data_to_kill);
7776

0 commit comments

Comments
 (0)