static int io_req_set_file(struct io_submit_state *state, struct io_kiocb *req)
{
	struct sqe_submit *s = &req->submit;
	struct io_ring_ctx *ctx = req->ctx;
	unsigned flags;
	int fd;

	flags = READ_ONCE(s->sqe->flags);
	fd = READ_ONCE(s->sqe->fd);

	if (flags & IOSQE_IO_DRAIN)
		req->flags |= REQ_F_IO_DRAIN;
	/*
	 * All io need record the previous position, if LINK vs DARIN,
	 * it can be used to mark the position of the first IO in the
	 * link list.
	 */
	req->sequence = s->sequence;

	if (!io_op_needs_file(s->sqe))
		return 0;

	if (flags & IOSQE_FIXED_FILE) {
		if (unlikely(!ctx->file_table ||
		    (unsigned) fd >= ctx->nr_user_files))
			return -EBADF;
		fd = array_index_nospec(fd, ctx->nr_user_files);
		req->file = io_file_from_index(ctx, fd);
		if (!req->file)
			return -EBADF;
		req->flags |= REQ_F_FIXED_FILE;
	} else {
		if (s->needs_fixed_file)
			return -EBADF;
		trace_io_uring_file_get(ctx, fd);
		req->file = io_file_get(state, fd);
		if (unlikely(!req->file))
			return -EBADF;
	}

	return 0;
}
static int io_req_set_file(struct io_submit_state *state, struct io_kiocb *req)
{
	struct sqe_submit *s = &req->submit;
	struct io_ring_ctx *ctx = req->ctx;
	unsigned flags;
	int fd;

	flags = READ_ONCE(s->sqe->flags);
	fd = READ_ONCE(s->sqe->fd);

	if (flags & IOSQE_IO_DRAIN)
		req->flags |= REQ_F_IO_DRAIN;
	 
	req->sequence = s->sequence;

	if (!io_op_needs_file(s->sqe))
		return 0;

	if (flags & IOSQE_FIXED_FILE) {
		if (unlikely(!ctx->file_table ||
		    (unsigned) fd >= ctx->nr_user_files))
			return -EBADF;
		fd = array_index_nospec(fd, ctx->nr_user_files);
		req->file = io_file_from_index(ctx, fd);
		if (!req->file)
			return -EBADF;
		req->flags |= REQ_F_FIXED_FILE;
	} else {
		if (s->needs_fixed_file)
			return -EBADF;
		trace_io_uring_file_get(ctx, fd);
		req->file = io_file_get(state, fd);
		if (unlikely(!req->file))
			return -EBADF;
	}

	return 0;
}