[PATCH v2 2/3] io_uring: Pass whole sqe to commands

Christoph Hellwig hch at lst.de
Mon Apr 24 00:23:39 PDT 2023


On Fri, Apr 21, 2023 at 04:44:39AM -0700, Breno Leitao wrote:
> -	struct ublksrv_io_cmd *ub_cmd = (struct ublksrv_io_cmd *)cmd->cmd;
> +	struct ublksrv_io_cmd *ub_cmd = (struct ublksrv_io_cmd *)cmd->sqe->cmd;

As mentioned in my (late) reply to the previous series, please
add a helper like:

static inline const void *io_uring_sqe_cmd(struct io_uring_sqe *sqe)
{
	return sqe->cmd;
}

and then avoid all these casts.

>  int io_uring_cmd_prep_async(struct io_kiocb *req)
>  {
>  	struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
> +	size_t size = uring_sqe_size(req->ctx);
>  
>  	BUILD_BUG_ON(uring_cmd_pdu_size(0) != 16);
>  	BUILD_BUG_ON(uring_cmd_pdu_size(1) != 80);
>  
> +	memcpy(req->async_data, ioucmd->sqe, size);
> +	ioucmd->sqe = req->async_data;

This can skip the size local variable now.



More information about the Linux-nvme mailing list