]> Git Repo - linux.git/commitdiff
nvme: wire up fixed buffer support for nvme passthrough
authorKanchan Joshi <[email protected]>
Fri, 30 Sep 2022 06:27:49 +0000 (11:57 +0530)
committerJens Axboe <[email protected]>
Fri, 30 Sep 2022 13:51:13 +0000 (07:51 -0600)
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]>
drivers/nvme/host/ioctl.c

index 7a41caa9bfd2a7aa2961a775d2cba1e61a92aa30..81f5550b670da05c55d961fed84368c858e0325d 100644 (file)
@@ -95,8 +95,22 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
        void *meta = NULL;
        int ret;
 
-       ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer), bufflen,
-                       GFP_KERNEL, vec, 0, 0, rq_data_dir(req));
+       if (ioucmd && (ioucmd->flags & IORING_URING_CMD_FIXED)) {
+               struct iov_iter iter;
+
+               /* fixedbufs is only for non-vectored io */
+               if (WARN_ON_ONCE(vec))
+                       return -EINVAL;
+               ret = io_uring_cmd_import_fixed(ubuffer, bufflen,
+                               rq_data_dir(req), &iter, ioucmd);
+               if (ret < 0)
+                       goto out;
+               ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
+       } else {
+               ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer),
+                               bufflen, GFP_KERNEL, vec, 0, 0,
+                               rq_data_dir(req));
+       }
 
        if (ret)
                goto out;
This page took 0.057348 seconds and 4 git commands to generate.