]> www.infradead.org Git - nvme.git/commitdiff
nvme: enable vectored registered bufs for passthrough cmds
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 20 May 2025 15:22:18 +0000 (16:22 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 4 Jun 2025 07:51:10 +0000 (09:51 +0200)
nvme already supports registered buffers for non-vectored io_uring
passthrough commands, enable it for the vectored mode as well. It takes
an iovec, each entry of which should contain a range within the same
registered buffer specificied in sqe->buf_index.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/ioctl.c

index f29107d95ff26d5bd961c97868df5ed47c21aa42..5d5f8b07cdec28e9a1e25b918d018db02545f0cd 100644 (file)
@@ -493,13 +493,15 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
        d.timeout_ms = READ_ONCE(cmd->timeout_ms);
 
        if (d.data_len && (ioucmd->flags & IORING_URING_CMD_FIXED)) {
-               /* fixedbufs is only for non-vectored io */
-               if (vec)
-                       return -EINVAL;
+               int ddir = nvme_is_write(&c) ? WRITE : READ;
 
-               ret = io_uring_cmd_import_fixed(d.addr, d.data_len,
-                       nvme_is_write(&c) ? WRITE : READ, &iter, ioucmd,
-                       issue_flags);
+               if (vec)
+                       ret = io_uring_cmd_import_fixed_vec(ioucmd,
+                                       u64_to_user_ptr(d.addr), d.data_len,
+                                       ddir, &iter, issue_flags);
+               else
+                       ret = io_uring_cmd_import_fixed(d.addr, d.data_len,
+                                       ddir, &iter, ioucmd, issue_flags);
                if (ret < 0)
                        return ret;