Skip to content

Commit c87fd58

Browse files
isilenceaxboe
authored andcommitted
io_uring/rsrc: simplify single file node switching
At maximum io_install_fixed_file() removes only one file, so no need to keep needs_switch state and we can call io_rsrc_node_switch() right after removal. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/37cfb46f46160f81dced79f646e97db608994574.1681395792.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 9a57fff commit c87fd58

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

io_uring/filetable.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
6464
u32 slot_index)
6565
__must_hold(&req->ctx->uring_lock)
6666
{
67-
bool needs_switch = false;
6867
struct io_fixed_file *file_slot;
6968
int ret;
7069

@@ -83,16 +82,17 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
8382

8483
ret = io_rsrc_node_switch_start(ctx);
8584
if (ret)
86-
goto err;
85+
return ret;
8786

8887
old_file = (struct file *)(file_slot->file_ptr & FFS_MASK);
8988
ret = io_queue_rsrc_removal(ctx->file_data, slot_index,
9089
ctx->rsrc_node, old_file);
9190
if (ret)
92-
goto err;
91+
return ret;
92+
9393
file_slot->file_ptr = 0;
9494
io_file_bitmap_clear(&ctx->file_table, slot_index);
95-
needs_switch = true;
95+
io_rsrc_node_switch(ctx, ctx->file_data);
9696
}
9797

9898
ret = io_scm_file_account(ctx, file);
@@ -101,9 +101,6 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
101101
io_fixed_file_set(file_slot, file);
102102
io_file_bitmap_set(&ctx->file_table, slot_index);
103103
}
104-
err:
105-
if (needs_switch)
106-
io_rsrc_node_switch(ctx, ctx->file_data);
107104
return ret;
108105
}
109106

0 commit comments

Comments
 (0)