Re: [PATCH 08/17] nvme: enable passthrough with fixed-buffer

Christoph Hellwig
2022-03-10T08:32:41Z

On Tue, Mar 08, 2022 at 08:50:56PM +0530, Kanchan Joshi wrote:
> +/* Unlike blk_rq_map_user () this is only for fixed-buffer async passthrough. */
> +int blk_rq_map_user_fixedb(struct request_queue *q, struct request *rq,
> + u64 ubuf, unsigned long len, gfp_t gfp_mask,
> + struct io_uring_cmd *ioucmd)
> +{

This doesn't belong into a patch title nvme. Also please add a proper
kernel-doc comment.

> +EXPORT_SYMBOL(blk_rq_map_user_fixedb);

EXPORT_SYMBOL_GPL, please.

> +static inline bool nvme_is_fixedb_passthru(struct io_uring_cmd *ioucmd)
> +{
> + return ((ioucmd) && (ioucmd->flags & IO_URING_F_UCMD_FIXEDBUFS));
> +}

No need for the outer and first set of inner braces.

> +
> static int nvme_submit_user_cmd(struct request_queue *q,
> - struct nvme_command *cmd, void __user *ubuffer,
> + struct nvme_command *cmd, u64 ubuffer,
> unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
> u32 meta_seed, u64 *result, unsigned timeout,
> struct io_uring_cmd *ioucmd)
> @@ -152,8 +157,12 @@ static int nvme_submit_user_cmd(struct request_queue *q,
> nvme_req(req)->flags |= NVME_REQ_USERCMD;
>
> if (ubuffer && bufflen) {
> - ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,
> - GFP_KERNEL);
> + if (likely(nvme_is_fixedb_passthru(ioucmd)))
> + ret = blk_rq_map_user_fixedb(q, req, ubuffer, bufflen,
> + GFP_KERNEL, ioucmd);
> + else
> + ret = blk_rq_map_user(q, req, NULL, nvme_to_user_ptr(ubuffer),

Overly long line.