Skip to content

Commit 23fd22e

Browse files
Kanchan Joshiaxboe
authored andcommitted
nvme: wire up fixed buffer support for nvme passthrough
if io_uring sends passthrough command with IORING_URING_CMD_FIXED flag, use the pre-registered buffer for IO (non-vectored variant). Pass the buffer/length to io_uring and get the bvec iterator for the range. Next, pass this bvec to block-layer and obtain a bio/request for subsequent processing. Signed-off-by: Kanchan Joshi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4d17448 commit 23fd22e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

drivers/nvme/host/ioctl.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,22 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
9595
void *meta = NULL;
9696
int ret;
9797

98-
ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer), bufflen,
99-
GFP_KERNEL, vec, 0, 0, rq_data_dir(req));
98+
if (ioucmd && (ioucmd->flags & IORING_URING_CMD_FIXED)) {
99+
struct iov_iter iter;
100+
101+
/* fixedbufs is only for non-vectored io */
102+
if (WARN_ON_ONCE(vec))
103+
return -EINVAL;
104+
ret = io_uring_cmd_import_fixed(ubuffer, bufflen,
105+
rq_data_dir(req), &iter, ioucmd);
106+
if (ret < 0)
107+
goto out;
108+
ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
109+
} else {
110+
ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer),
111+
bufflen, GFP_KERNEL, vec, 0, 0,
112+
rq_data_dir(req));
113+
}
100114

101115
if (ret)
102116
goto out;

0 commit comments

Comments
 (0)