aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-01-18 10:16:33 -0500
committerJens Axboe <axboe@fb.com>2015-02-05 11:30:43 -0500
commit37f19e57a0de3c4a3417aa13ff4d04f1e0dee4b3 (patch)
tree07851f8df6b3f2c568a557dab978901dc4129a0c /block
parent75c72b8366f35f2e5cf1b841b52095948878b794 (diff)
block: merge __bio_map_user_iov into bio_map_user_iov
And also remove the unused bdev argument. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r--block/bio.c56
-rw-r--r--block/blk-map.c2
2 files changed, 21 insertions, 37 deletions
diff --git a/block/bio.c b/block/bio.c
index a69a9c9e7c93..0723d4ce8589 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1244,10 +1244,18 @@ out_bmd:
1244 return ERR_PTR(ret); 1244 return ERR_PTR(ret);
1245} 1245}
1246 1246
1247static struct bio *__bio_map_user_iov(struct request_queue *q, 1247/**
1248 struct block_device *bdev, 1248 * bio_map_user_iov - map user iovec into bio
1249 const struct iov_iter *iter, 1249 * @q: the struct request_queue for the bio
1250 gfp_t gfp_mask) 1250 * @iter: iovec iterator
1251 * @gfp_mask: memory allocation flags
1252 *
1253 * Map the user space address into a bio suitable for io to a block
1254 * device. Returns an error pointer in case of error.
1255 */
1256struct bio *bio_map_user_iov(struct request_queue *q,
1257 const struct iov_iter *iter,
1258 gfp_t gfp_mask)
1251{ 1259{
1252 int j; 1260 int j;
1253 int nr_pages = 0; 1261 int nr_pages = 0;
@@ -1343,8 +1351,15 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
1343 if (iter->type & WRITE) 1351 if (iter->type & WRITE)
1344 bio->bi_rw |= REQ_WRITE; 1352 bio->bi_rw |= REQ_WRITE;
1345 1353
1346 bio->bi_bdev = bdev;
1347 bio->bi_flags |= (1 << BIO_USER_MAPPED); 1354 bio->bi_flags |= (1 << BIO_USER_MAPPED);
1355
1356 /*
1357 * subtle -- if __bio_map_user() ended up bouncing a bio,
1358 * it would normally disappear when its bi_end_io is run.
1359 * however, we need it for the unmap, so grab an extra
1360 * reference to it
1361 */
1362 bio_get(bio);
1348 return bio; 1363 return bio;
1349 1364
1350 out_unmap: 1365 out_unmap:
@@ -1359,37 +1374,6 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
1359 return ERR_PTR(ret); 1374 return ERR_PTR(ret);
1360} 1375}
1361 1376
1362/**
1363 * bio_map_user_iov - map user iovec into bio
1364 * @q: the struct request_queue for the bio
1365 * @bdev: destination block device
1366 * @iter: iovec iterator
1367 * @gfp_mask: memory allocation flags
1368 *
1369 * Map the user space address into a bio suitable for io to a block
1370 * device. Returns an error pointer in case of error.
1371 */
1372struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev,
1373 const struct iov_iter *iter,
1374 gfp_t gfp_mask)
1375{
1376 struct bio *bio;
1377
1378 bio = __bio_map_user_iov(q, bdev, iter, gfp_mask);
1379 if (IS_ERR(bio))
1380 return bio;
1381
1382 /*
1383 * subtle -- if __bio_map_user() ended up bouncing a bio,
1384 * it would normally disappear when its bi_end_io is run.
1385 * however, we need it for the unmap, so grab an extra
1386 * reference to it
1387 */
1388 bio_get(bio);
1389
1390 return bio;
1391}
1392
1393static void __bio_unmap_user(struct bio *bio) 1377static void __bio_unmap_user(struct bio *bio)
1394{ 1378{
1395 struct bio_vec *bvec; 1379 struct bio_vec *bvec;
diff --git a/block/blk-map.c b/block/blk-map.c
index 30e6bb871c5c..0f22911f17dc 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -88,7 +88,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
88 if (unaligned || (q->dma_pad_mask & iter->count) || map_data) 88 if (unaligned || (q->dma_pad_mask & iter->count) || map_data)
89 bio = bio_copy_user_iov(q, map_data, iter, gfp_mask); 89 bio = bio_copy_user_iov(q, map_data, iter, gfp_mask);
90 else 90 else
91 bio = bio_map_user_iov(q, NULL, iter, gfp_mask); 91 bio = bio_map_user_iov(q, iter, gfp_mask);
92 92
93 if (IS_ERR(bio)) 93 if (IS_ERR(bio))
94 return PTR_ERR(bio); 94 return PTR_ERR(bio);