* [PATCH 0/2] nvme-passthru with vectored-io
[not found] <CGME20220127083033epcas5p3ce9565e4b5e21e897571e48e73e4f9af@epcas5p3.samsung.com>
@ 2022-01-27 8:25 ` Kanchan Joshi
[not found] ` <CGME20220127083034epcas5p4aaafaf1f40c21a383e985d6f6568cbef@epcas5p4.samsung.com>
[not found] ` <CGME20220127083035epcas5p3e3760849513fb7939757f4e6678405a0@epcas5p3.samsung.com>
0 siblings, 2 replies; 9+ messages in thread
From: Kanchan Joshi @ 2022-01-27 8:25 UTC (permalink / raw)
To: hch, kbusch, axboe; +Cc: linux-nvme, linux-block, joshiiitr
NVMe passthru takes a single buffer pointer.
This enables using multiple buffers for passthru, similiar to
readv/writev.
First patch is prep, while second one adds vectored-io abililty to
NVME_IOCTL_IO64_CMD.
Kanchan Joshi (2):
block: introduce and export blk_rq_map_user_vec
nvme: add vectored-io support for user passthru
block/blk-map.c | 19 +++++++++++++++++++
drivers/nvme/host/ioctl.c | 9 ++++++---
include/linux/blk-mq.h | 2 ++
include/uapi/linux/nvme_ioctl.h | 4 ++++
4 files changed, 31 insertions(+), 3 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] block: introduce and export blk_rq_map_user_vec
[not found] ` <CGME20220127083034epcas5p4aaafaf1f40c21a383e985d6f6568cbef@epcas5p4.samsung.com>
@ 2022-01-27 8:25 ` Kanchan Joshi
2022-01-27 9:27 ` Christoph Hellwig
2022-01-28 9:04 ` Chaitanya Kulkarni
0 siblings, 2 replies; 9+ messages in thread
From: Kanchan Joshi @ 2022-01-27 8:25 UTC (permalink / raw)
To: hch, kbusch, axboe; +Cc: linux-nvme, linux-block, joshiiitr
Similiar to blk_rq_map_user except that it operates on iovec.
This is a prep patch.
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
block/blk-map.c | 19 +++++++++++++++++++
include/linux/blk-mq.h | 2 ++
2 files changed, 21 insertions(+)
diff --git a/block/blk-map.c b/block/blk-map.c
index 4526adde0156..7fe45df3e580 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -577,6 +577,25 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
}
EXPORT_SYMBOL(blk_rq_map_user);
+int blk_rq_map_user_vec(struct request_queue *q, struct request *rq,
+ struct rq_map_data *map_data, void __user *uvec,
+ unsigned long nr_vecs, gfp_t gfp_mask)
+{
+ struct iovec fast_iov[UIO_FASTIOV];
+ struct iovec *iov = fast_iov;
+ struct iov_iter iter;
+ int ret;
+
+ ret = import_iovec(rq_data_dir(rq), uvec, nr_vecs, UIO_FASTIOV, &iov, &iter);
+ if (unlikely(ret < 0))
+ return ret;
+ ret = blk_rq_map_user_iov(q, rq, NULL, &iter, gfp_mask);
+ kfree(iov);
+
+ return ret;
+}
+EXPORT_SYMBOL(blk_rq_map_user_vec);
+
/**
* blk_rq_unmap_user - unmap a request with user data
* @bio: start of bio list
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index d319ffa59354..0fda666d2230 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -966,6 +966,8 @@ struct rq_map_data {
int blk_rq_map_user(struct request_queue *, struct request *,
struct rq_map_data *, void __user *, unsigned long, gfp_t);
+int blk_rq_map_user_vec(struct request_queue *, struct request *,
+ struct rq_map_data *, void __user *, unsigned long, gfp_t);
int blk_rq_map_user_iov(struct request_queue *, struct request *,
struct rq_map_data *, const struct iov_iter *, gfp_t);
int blk_rq_unmap_user(struct bio *);
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] nvme: add vectored-io support for user passthru
[not found] ` <CGME20220127083035epcas5p3e3760849513fb7939757f4e6678405a0@epcas5p3.samsung.com>
@ 2022-01-27 8:25 ` Kanchan Joshi
2022-01-27 9:29 ` Christoph Hellwig
0 siblings, 1 reply; 9+ messages in thread
From: Kanchan Joshi @ 2022-01-27 8:25 UTC (permalink / raw)
To: hch, kbusch, axboe; +Cc: linux-nvme, linux-block, joshiiitr
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(-)
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] block: introduce and export blk_rq_map_user_vec
2022-01-27 8:25 ` [PATCH 1/2] block: introduce and export blk_rq_map_user_vec Kanchan Joshi
@ 2022-01-27 9:27 ` Christoph Hellwig
2022-01-27 14:38 ` Kanchan Joshi
2022-01-28 9:04 ` Chaitanya Kulkarni
1 sibling, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2022-01-27 9:27 UTC (permalink / raw)
To: Kanchan Joshi; +Cc: hch, kbusch, axboe, linux-nvme, linux-block, joshiiitr
On Thu, Jan 27, 2022 at 01:55:35PM +0530, Kanchan Joshi wrote:
> Similiar to blk_rq_map_user except that it operates on iovec.
> This is a prep patch.
>
> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> ---
> block/blk-map.c | 19 +++++++++++++++++++
> include/linux/blk-mq.h | 2 ++
> 2 files changed, 21 insertions(+)
>
> diff --git a/block/blk-map.c b/block/blk-map.c
> index 4526adde0156..7fe45df3e580 100644
> --- a/block/blk-map.c
> +++ b/block/blk-map.c
> @@ -577,6 +577,25 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
> }
> EXPORT_SYMBOL(blk_rq_map_user);
>
> +int blk_rq_map_user_vec(struct request_queue *q, struct request *rq,
> + struct rq_map_data *map_data, void __user *uvec,
> + unsigned long nr_vecs, gfp_t gfp_mask)
> +{
> + struct iovec fast_iov[UIO_FASTIOV];
> + struct iovec *iov = fast_iov;
> + struct iov_iter iter;
> + int ret;
> +
> + ret = import_iovec(rq_data_dir(rq), uvec, nr_vecs, UIO_FASTIOV, &iov, &iter);
> + if (unlikely(ret < 0))
> + return ret;
> + ret = blk_rq_map_user_iov(q, rq, NULL, &iter, gfp_mask);
> + kfree(iov);
> +
> + return ret;
I see very little point in adding this function vs just open coding it.
Also please don't add overly long lines.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] nvme: add vectored-io support for user passthru
2022-01-27 8:25 ` [PATCH 2/2] nvme: add vectored-io support for user passthru Kanchan Joshi
@ 2022-01-27 9:29 ` Christoph Hellwig
2022-01-27 14:43 ` Kanchan Joshi
0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2022-01-27 9:29 UTC (permalink / raw)
To: Kanchan Joshi; +Cc: hch, kbusch, axboe, linux-nvme, linux-block, joshiiitr
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] block: introduce and export blk_rq_map_user_vec
2022-01-27 9:27 ` Christoph Hellwig
@ 2022-01-27 14:38 ` Kanchan Joshi
0 siblings, 0 replies; 9+ messages in thread
From: Kanchan Joshi @ 2022-01-27 14:38 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Kanchan Joshi, Keith Busch, Jens Axboe, linux-nvme, linux-block
On Thu, Jan 27, 2022 at 2:57 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Thu, Jan 27, 2022 at 01:55:35PM +0530, Kanchan Joshi wrote:
> > Similiar to blk_rq_map_user except that it operates on iovec.
> > This is a prep patch.
> >
> > Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
> > Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> > ---
> > block/blk-map.c | 19 +++++++++++++++++++
> > include/linux/blk-mq.h | 2 ++
> > 2 files changed, 21 insertions(+)
> >
> > diff --git a/block/blk-map.c b/block/blk-map.c
> > index 4526adde0156..7fe45df3e580 100644
> > --- a/block/blk-map.c
> > +++ b/block/blk-map.c
> > @@ -577,6 +577,25 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
> > }
> > EXPORT_SYMBOL(blk_rq_map_user);
> >
> > +int blk_rq_map_user_vec(struct request_queue *q, struct request *rq,
> > + struct rq_map_data *map_data, void __user *uvec,
> > + unsigned long nr_vecs, gfp_t gfp_mask)
> > +{
> > + struct iovec fast_iov[UIO_FASTIOV];
> > + struct iovec *iov = fast_iov;
> > + struct iov_iter iter;
> > + int ret;
> > +
> > + ret = import_iovec(rq_data_dir(rq), uvec, nr_vecs, UIO_FASTIOV, &iov, &iter);
> > + if (unlikely(ret < 0))
> > + return ret;
> > + ret = blk_rq_map_user_iov(q, rq, NULL, &iter, gfp_mask);
> > + kfree(iov);
> > +
> > + return ret;
>
> I see very little point in adding this function vs just open coding it.
Fine, I will kill this and open-code in nvme instead.
--
Kanchan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] nvme: add vectored-io support for user passthru
2022-01-27 9:29 ` Christoph Hellwig
@ 2022-01-27 14:43 ` Kanchan Joshi
2022-01-28 9:08 ` Chaitanya Kulkarni
0 siblings, 1 reply; 9+ messages in thread
From: Kanchan Joshi @ 2022-01-27 14:43 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Kanchan Joshi, Keith Busch, Jens Axboe, linux-nvme, linux-block
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?
--
Kanchan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] block: introduce and export blk_rq_map_user_vec
2022-01-27 8:25 ` [PATCH 1/2] block: introduce and export blk_rq_map_user_vec Kanchan Joshi
2022-01-27 9:27 ` Christoph Hellwig
@ 2022-01-28 9:04 ` Chaitanya Kulkarni
1 sibling, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2022-01-28 9:04 UTC (permalink / raw)
To: Kanchan Joshi, hch, kbusch, axboe; +Cc: linux-nvme, linux-block, joshiiitr
On 1/27/22 12:25 AM, Kanchan Joshi wrote:
> External email: Use caution opening links or attachments
>
>
> Similiar to blk_rq_map_user except that it operates on iovec.
> This is a prep patch.
>
> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> ---
Did you run checkpatch.pl ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] nvme: add vectored-io support for user passthru
2022-01-27 14:43 ` Kanchan Joshi
@ 2022-01-28 9:08 ` Chaitanya Kulkarni
0 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2022-01-28 9:08 UTC (permalink / raw)
To: Kanchan Joshi, Christoph Hellwig
Cc: Kanchan Joshi, Keith Busch, Jens Axboe, linux-nvme, linux-block
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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-01-28 9:08 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20220127083033epcas5p3ce9565e4b5e21e897571e48e73e4f9af@epcas5p3.samsung.com>
2022-01-27 8:25 ` [PATCH 0/2] nvme-passthru with vectored-io Kanchan Joshi
[not found] ` <CGME20220127083034epcas5p4aaafaf1f40c21a383e985d6f6568cbef@epcas5p4.samsung.com>
2022-01-27 8:25 ` [PATCH 1/2] block: introduce and export blk_rq_map_user_vec Kanchan Joshi
2022-01-27 9:27 ` Christoph Hellwig
2022-01-27 14:38 ` Kanchan Joshi
2022-01-28 9:04 ` Chaitanya Kulkarni
[not found] ` <CGME20220127083035epcas5p3e3760849513fb7939757f4e6678405a0@epcas5p3.samsung.com>
2022-01-27 8:25 ` [PATCH 2/2] nvme: add vectored-io support for user passthru Kanchan Joshi
2022-01-27 9:29 ` Christoph Hellwig
2022-01-27 14:43 ` Kanchan Joshi
2022-01-28 9:08 ` Chaitanya Kulkarni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.