diff mbox series

[2/2] nvme: add vectored-io support for user passthru

Message ID 20220127082536.7243-3-joshi.k@samsung.com (mailing list archive)
State New, archived
Headers show
Series nvme-passthru with vectored-io | expand

Commit Message

Kanchan Joshi Jan. 27, 2022, 8:25 a.m. UTC
wire up support for passthru that takes an array of buffers (using
iovec). Enable it for NVME_IOCTL_IO64_CMD; same ioctl code to be used
with following differences -

1. NVME_IOVEC to be set as cmd.flags
2. cmd.addr, base addr of user iovec array
3. cmd.data_len, count of iovec array elements

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
 drivers/nvme/host/ioctl.c       | 9 ++++++---
 include/uapi/linux/nvme_ioctl.h | 4 ++++
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Jan. 27, 2022, 9:29 a.m. UTC | #1
On Thu, Jan 27, 2022 at 01:55:36PM +0530, Kanchan Joshi wrote:
> wire up support for passthru that takes an array of buffers (using
> iovec). Enable it for NVME_IOCTL_IO64_CMD; same ioctl code to be used
> with following differences -

Flags overloading for a completely different ABI is a bad idea.
Please add a separate ioctl instead.
Kanchan Joshi Jan. 27, 2022, 2:43 p.m. UTC | #2
On Thu, Jan 27, 2022 at 2:59 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Thu, Jan 27, 2022 at 01:55:36PM +0530, Kanchan Joshi wrote:
> > wire up support for passthru that takes an array of buffers (using
> > iovec). Enable it for NVME_IOCTL_IO64_CMD; same ioctl code to be used
> > with following differences -
>
> Flags overloading for a completely different ABI is a bad idea.
> Please add a separate ioctl instead.

Hope "NVME_IOCTL_IO64_VEC_CMD" sounds fine for the new one?
Chaitanya Kulkarni Jan. 28, 2022, 9:08 a.m. UTC | #3
Flags overloading for a completely different ABI is a bad idea.
>> Please add a separate ioctl instead.
> 
> Hope "NVME_IOCTL_IO64_VEC_CMD" sounds fine for the new one?
> 

sounds reasonable to me..

> --
> Kanchan
>
diff mbox series

Patch

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 22314962842d..3a896443e110 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -65,6 +65,7 @@  static int nvme_submit_user_cmd(struct request_queue *q,
 	struct bio *bio = NULL;
 	void *meta = NULL;
 	int ret;
+	u8 cmd_flags = cmd->common.flags;
 
 	req = nvme_alloc_request(q, cmd, 0);
 	if (IS_ERR(req))
@@ -75,7 +76,11 @@  static int nvme_submit_user_cmd(struct request_queue *q,
 	nvme_req(req)->flags |= NVME_REQ_USERCMD;
 
 	if (ubuffer && bufflen) {
-		ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,
+		if (!(cmd_flags & NVME_IOVEC))
+			ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,
+				GFP_KERNEL);
+		else
+			ret = blk_rq_map_user_vec(q, req, NULL, ubuffer, bufflen,
 				GFP_KERNEL);
 		if (ret)
 			goto out;
@@ -246,8 +251,6 @@  static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 		return -EACCES;
 	if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
 		return -EFAULT;
-	if (cmd.flags)
-		return -EINVAL;
 	if (!nvme_validate_passthru_nsid(ctrl, ns, cmd.nsid))
 		return -EINVAL;
 
diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h
index d99b5a772698..d4999e3930f8 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h
@@ -9,6 +9,10 @@ 
 
 #include <linux/types.h>
 
+enum nvme_ioc_flags {
+	NVME_IOVEC	= 1 << 0 /* vectored io */
+};
+
 struct nvme_user_io {
 	__u8	opcode;
 	__u8	flags;