diff mbox series

[1/2] block: introduce and export blk_rq_map_user_vec

Message ID 20220127082536.7243-2-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
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(+)

Comments

Christoph Hellwig Jan. 27, 2022, 9:27 a.m. UTC | #1
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.
Kanchan Joshi Jan. 27, 2022, 2:38 p.m. UTC | #2
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.
Chaitanya Kulkarni Jan. 28, 2022, 9:04 a.m. UTC | #3
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 ?
diff mbox series

Patch

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 *);