[PATCH] nvme/io_uring: enable dma-buf backed passthrough I/O
Pavel Begunkov
asml.silence at gmail.com
Sun Oct 18 15:06:16 PDT 2026
On 10/16/26 11:34, Anuj Gupta wrote:
> From: Anuj Gupta <anuj20.g at samsung.com>
...> static void nvme_add_ns_cdev(struct nvme_ns *ns)
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 3aa5d2f2dfbb..6343da1f6c05 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -458,6 +458,7 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
> status = blk_status_to_errno(err);
> }
> io_uring_cmd_set_res32(ioucmd, status, result);
> + io_uring_cmd_detach_dmabuf(ioucmd);
It's not great spilling the responsibility for [de,a]ttaching
between nvme and uring_cmd code. Is there a way to stash it
all under io_uring?
...> @@ -275,11 +284,16 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
> unsigned int issue_flags)
> {
> struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);
> + int ret;
>
> if (WARN_ON_ONCE(!(ioucmd->flags & IORING_URING_CMD_FIXED)))
> return -EINVAL;
>
> - return io_import_reg_buf(req, iter, ubuf, len, rw, issue_flags);
> + ret = __io_import_reg_buf(req, iter, ubuf, len, rw, issue_flags,
> + IO_REGBUF_IMPORT_ALLOW_DMABUF);
> + if (ret)
> + return ret;
Let's explicitly pass a flag allowing to import dma-buf from
nvme / other commands. It'd be feeble otherwise. We can create
a dma-buf for a block file now, imagine someone adds a command
for those that also uses registered buffers but doesn't expect
dma-buf.
> + return io_attach_dmabuf_map(req, iter, issue_flags);
> }
> EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed);
>
--
Pavel Begunkov
More information about the Linux-nvme
mailing list