[PATCH for-next v11 13/13] nvme: Use blk_rq_map_user_io helper

Anuj Gupta anuj20.g at samsung.com
Thu Sep 29 05:06:32 PDT 2022


User blk_rq_map_user_io instead of duplicating the same code at
different places

Signed-off-by: Anuj Gupta <anuj20.g at samsung.com>
---
 drivers/nvme/host/ioctl.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 25a68e8c60db..a3f22bbe511a 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -106,21 +106,12 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
 		if (ret < 0)
 			goto out;
 		ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
-	} else if (vec) {
-		struct iovec fast_iov[UIO_FASTIOV];
-		struct iovec *iov = fast_iov;
-		struct iov_iter iter;
-
-		ret = import_iovec(rq_data_dir(req), nvme_to_user_ptr(ubuffer),
-				bufflen, UIO_FASTIOV, &iov, &iter);
-		if (ret < 0)
-			goto out;
-		ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
-		kfree(iov);
 	} else {
-		ret = blk_rq_map_user(q, req, NULL,
-				nvme_to_user_ptr(ubuffer), bufflen, GFP_KERNEL);
+		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;
 	bio = req->bio;
-- 
2.25.1




More information about the Linux-nvme mailing list