public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bio: switch to iov_iter_{npages,alignment}
@ 2015-04-24 22:45 Ming Lin
  2015-04-25  9:46 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Ming Lin @ 2015-04-24 22:45 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-kernel, Christoph Hellwig, Al Viro, Kent Overstreet,
	Ming Lin

Signed-off-by: Ming Lin <mlin@kernel.org>
---
 block/bio.c | 45 +++++++--------------------------------------
 1 file changed, 7 insertions(+), 38 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 05c2864..c3a6468 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1158,29 +1158,14 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
 	struct bio_map_data *bmd;
 	struct page *page;
 	struct bio *bio;
-	int i, ret;
+	int uninitialized_var(i), ret;
 	int nr_pages = 0;
 	unsigned int len = iter->count;
 	unsigned int offset = map_data ? map_data->offset & ~PAGE_MASK : 0;
 
-	for (i = 0; i < iter->nr_segs; i++) {
-		unsigned long uaddr;
-		unsigned long end;
-		unsigned long start;
-
-		uaddr = (unsigned long) iter->iov[i].iov_base;
-		end = (uaddr + iter->iov[i].iov_len + PAGE_SIZE - 1)
-			>> PAGE_SHIFT;
-		start = uaddr >> PAGE_SHIFT;
-
-		/*
-		 * Overflow, abort
-		 */
-		if (end < start)
-			return ERR_PTR(-EINVAL);
-
-		nr_pages += end - start;
-	}
+	nr_pages = iov_iter_npages(iter, INT_MAX);
+	if (!nr_pages)
+		return ERR_PTR(-EINVAL);
 
 	if (offset)
 		nr_pages++;
@@ -1292,26 +1277,10 @@ struct bio *bio_map_user_iov(struct request_queue *q,
 	struct iov_iter i;
 	struct iovec iov;
 
-	iov_for_each(iov, i, *iter) {
-		unsigned long uaddr = (unsigned long) iov.iov_base;
-		unsigned long len = iov.iov_len;
-		unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-		unsigned long start = uaddr >> PAGE_SHIFT;
-
-		/*
-		 * Overflow, abort
-		 */
-		if (end < start)
-			return ERR_PTR(-EINVAL);
-
-		nr_pages += end - start;
-		/*
-		 * buffer must be aligned to at least hardsector size for now
-		 */
-		if (uaddr & queue_dma_alignment(q))
-			return ERR_PTR(-EINVAL);
-	}
+	if (iov_iter_alignment(iter) & queue_dma_alignment(q))
+		return ERR_PTR(-EINVAL);
 
+	nr_pages = iov_iter_npages(iter, INT_MAX);
 	if (!nr_pages)
 		return ERR_PTR(-EINVAL);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bio: switch to iov_iter_{npages,alignment}
  2015-04-24 22:45 [PATCH] bio: switch to iov_iter_{npages,alignment} Ming Lin
@ 2015-04-25  9:46 ` Christoph Hellwig
  2015-05-06  7:16   ` Ming Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2015-04-25  9:46 UTC (permalink / raw)
  To: Ming Lin
  Cc: Jens Axboe, linux-kernel, Christoph Hellwig, Al Viro,
	Kent Overstreet

On Fri, Apr 24, 2015 at 03:45:23PM -0700, Ming Lin wrote:
> Signed-off-by: Ming Lin <mlin@kernel.org>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bio: switch to iov_iter_{npages,alignment}
  2015-04-25  9:46 ` Christoph Hellwig
@ 2015-05-06  7:16   ` Ming Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Ming Lin @ 2015-05-06  7:16 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jens Axboe, lkml, Al Viro, Kent Overstreet

On Sat, Apr 25, 2015 at 2:46 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Fri, Apr 24, 2015 at 03:45:23PM -0700, Ming Lin wrote:
>> Signed-off-by: Ming Lin <mlin@kernel.org>
>
> Looks good,
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Hi Jens,

Would you like to take this?

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-06  7:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-24 22:45 [PATCH] bio: switch to iov_iter_{npages,alignment} Ming Lin
2015-04-25  9:46 ` Christoph Hellwig
2015-05-06  7:16   ` Ming Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox