Skip to content

Commit

Permalink
io_uring: use io_file_from_index in io_msg_grab_file
Browse files Browse the repository at this point in the history
Use io_file_from_index instead of open coding it.

Signed-off-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jun 20, 2023
1 parent 60a666f commit f432c8c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions io_uring/msg_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,12 @@ static struct file *io_msg_grab_file(struct io_kiocb *req, unsigned int issue_fl
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
struct io_ring_ctx *ctx = req->ctx;
struct file *file = NULL;
unsigned long file_ptr;
int idx = msg->src_fd;

io_ring_submit_lock(ctx, issue_flags);
if (likely(idx < ctx->nr_user_files)) {
idx = array_index_nospec(idx, ctx->nr_user_files);
file_ptr = io_fixed_file_slot(&ctx->file_table, idx)->file_ptr;
file = (struct file *) (file_ptr & FFS_MASK);
file = io_file_from_index(&ctx->file_table, idx);
if (file)
get_file(file);
}
Expand Down

0 comments on commit f432c8c

Please sign in to comment.