diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-09-23 16:24:59 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-10-11 17:23:39 -0400 |
commit | b282cc766958af161249b7b04d50e3eae12a2a1c (patch) | |
tree | ac0f2291d2e4a304ffe851736d594c7778cf5ad8 /block | |
parent | 98f0bc99055da5797fae0c35d3d18261d59df9ac (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.c | 21 |
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, | |||
1324 | gfp_t gfp_mask) | 1324 | gfp_t gfp_mask) |
1325 | { | 1325 | { |
1326 | int j; | 1326 | int j; |
1327 | int nr_pages = 0; | ||
1328 | struct bio *bio; | 1327 | struct bio *bio; |
1329 | int ret; | 1328 | int ret; |
1330 | struct iov_iter i; | 1329 | struct iov_iter i; |
1331 | struct iovec iov; | ||
1332 | struct bio_vec *bvec; | 1330 | struct bio_vec *bvec; |
1333 | 1331 | ||
1334 | iov_for_each(iov, i, *iter) { | 1332 | if (!iov_iter_count(iter)) |
1335 | unsigned long uaddr = (unsigned long) iov.iov_base; | ||
1336 | unsigned long len = iov.iov_len; | ||
1337 | unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
1338 | unsigned long start = uaddr >> PAGE_SHIFT; | ||
1339 | |||
1340 | /* | ||
1341 | * Overflow, abort | ||
1342 | */ | ||
1343 | if (end < start) | ||
1344 | return ERR_PTR(-EINVAL); | ||
1345 | |||
1346 | nr_pages += end - start; | ||
1347 | } | ||
1348 | |||
1349 | if (!nr_pages) | ||
1350 | return ERR_PTR(-EINVAL); | 1333 | return ERR_PTR(-EINVAL); |
1351 | 1334 | ||
1352 | bio = bio_kmalloc(gfp_mask, nr_pages); | 1335 | bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES)); |
1353 | if (!bio) | 1336 | if (!bio) |
1354 | return ERR_PTR(-ENOMEM); | 1337 | return ERR_PTR(-ENOMEM); |
1355 | 1338 | ||