summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-09-23 16:24:59 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-10-11 17:23:39 -0400
commitb282cc766958af161249b7b04d50e3eae12a2a1c (patch)
treeac0f2291d2e4a304ffe851736d594c7778cf5ad8 /block
parent98f0bc99055da5797fae0c35d3d18261d59df9ac (diff)
bio_map_user_iov(): get rid of the iov_for_each()
Use iov_iter_npages() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'block')
-rw-r--r--block/bio.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/block/bio.c b/block/bio.c
index d851f68727f1..d1ca7eecc8aa 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1324,32 +1324,15 @@ struct bio *bio_map_user_iov(struct request_queue *q,
gfp_t gfp_mask)
{
int j;
- int nr_pages = 0;
struct bio *bio;
int ret;
struct iov_iter i;
- struct iovec iov;
struct bio_vec *bvec;
- 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;
- }
-
- if (!nr_pages)
+ if (!iov_iter_count(iter))
return ERR_PTR(-EINVAL);
- bio = bio_kmalloc(gfp_mask, nr_pages);
+ bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES));
if (!bio)
return ERR_PTR(-ENOMEM);